pub trait AuthProvider:
Send
+ Sync
+ Debug {
// Required methods
fn credential<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Credential, FaucetError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn provider_name(&self) -> &'static str;
// Provided method
fn invalidate<'life0, 'life1, 'async_trait>(
&'life0 self,
_stale: &'life1 Credential,
) -> Pin<Box<dyn Future<Output = Result<Credential, FaucetError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait { ... }
}Expand description
A live, shareable source of credentials.
One instance is shared (via Arc) across all connectors that reference it,
giving single-flight refresh: concurrent callers during a refresh await the
one in-flight fetch rather than each refreshing independently.
Object-safe — no generics or associated types, so it can be held as
Arc<dyn AuthProvider> (SharedAuthProvider).
Required Methods§
Sourcefn credential<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Credential, FaucetError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn credential<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Credential, FaucetError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Return a currently-valid credential, refreshing if needed.
Sourcefn provider_name(&self) -> &'static str
fn provider_name(&self) -> &'static str
Stable, non-empty name for diagnostics and metrics.
Provided Methods§
Sourcefn invalidate<'life0, 'life1, 'async_trait>(
&'life0 self,
_stale: &'life1 Credential,
) -> Pin<Box<dyn Future<Output = Result<Credential, FaucetError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn invalidate<'life0, 'life1, 'async_trait>(
&'life0 self,
_stale: &'life1 Credential,
) -> Pin<Box<dyn Future<Output = Result<Credential, FaucetError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Force a refresh iff the cached credential still equals stale
(compare-and-swap). Multiple connectors that hit a 401 with the same
token collapse into a single refresh; callers holding an already-rotated
token get the new one without triggering another fetch.
The default delegates to AuthProvider::credential; providers that
support refresh override it.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".