feat(client): Accept optional tokens in ClientBuilder::token#516
Open
jan-auer wants to merge 1 commit into
Open
feat(client): Accept optional tokens in ClientBuilder::token#516jan-auer wants to merge 1 commit into
jan-auer wants to merge 1 commit into
Conversation
Callers that hold an optional token previously had to guard the builder call, conditionally invoking `.token()` only when a value was present. Introduce an `IntoTokenProvider` trait, implemented for `TokenGenerator`, `String`, `&str`, and any `Option` of those. `ClientBuilder::token` now accepts an `Option` directly, leaving the client unauthenticated on `None`, so optional authentication needs no surrounding conditional.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #516 +/- ##
=======================================
Coverage 87.40% 87.41%
=======================================
Files 86 86
Lines 13893 13892 -1
=======================================
Hits 12143 12143
+ Misses 1750 1749 -1
☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
Clientbuilder supports chaining methods. However, there was no way to conditionally supply a token generator while chaining builder methods, which is unergonomic.ClientBuilder::tokennow accepts anOptiondirectly via a newIntoTokenProvidertrait. ANoneleaves the client unauthenticated. The new trait is also implemented for all types that were accepted previously, keeping backwards compatibility.This brings the Rust client in line with the Python client, which already accepts an optional token: