pub trait OAuthBearerTokenProvider:
Debug
+ Send
+ Sync {
// Required method
fn token(&self) -> TokenFuture<'_>;
// Provided methods
fn refresh(&self) -> TokenFuture<'_> { ... }
fn refresh_at(&self) -> RefreshFuture<'_> { ... }
fn background_refresh_enabled(&self) -> bool { ... }
}Expand description
A source of OAUTHBEARER tokens, as Kafka’s sasl.login.callback.handler.class
with an OAuthBearerTokenCallback is.
Each SASL exchange, including a re-authentication, asks for a token.
Required Methods§
Sourcefn token(&self) -> TokenFuture<'_>
fn token(&self) -> TokenFuture<'_>
Provided Methods§
Sourcefn refresh(&self) -> TokenFuture<'_>
fn refresh(&self) -> TokenFuture<'_>
Fetch a new token even when a cached one has not reached its refresh
time, as Kafka’s ExpiringCredentialRefreshingLogin re-logs in once
its refresh timer fires. spawn_background_refresh calls this at
each Self::refresh_at; a provider that caches nothing can leave
the default, which is Self::token.
§Errors
Returns a description when no token is available.
Sourcefn refresh_at(&self) -> RefreshFuture<'_>
fn refresh_at(&self) -> RefreshFuture<'_>
The time a cached token should next be refreshed, once
Self::token has fetched one. spawn_background_refresh polls
this to know when to wake up and fetch proactively; a provider that
caches nothing can leave the default, which never schedules a
background fetch.
Sourcefn background_refresh_enabled(&self) -> bool
fn background_refresh_enabled(&self) -> bool
Whether spawn_background_refresh should run a background task for
this provider.
Kafka’s ExpiringCredentialRefreshingLogin background thread always
runs once a login completes. krabka instead makes starting the
equivalent task an explicit call, so building a provider outside a
Tokio runtime never panics; this flag is each provider’s own opt-in
for that call, and it defaults to true so a caller that does invoke
spawn_background_refresh gets Kafka’s normal, always-on behavior
unless it explicitly turns the flag off.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".