pub trait TokenStore: Send + Sync {
// Required methods
fn load(&self) -> impl Future<Output = Option<Token>> + Send;
fn save(&self, token: &Token) -> impl Future<Output = ()> + Send;
}Expand description
Pluggable persistent cache for service tokens.
Implementations are consulted by AutoRefresh whenever it has no
in-memory token (cold start), and written to after every successful
refresh or initial authentication. Implementations should treat both
methods as best-effort — load returns None for “no token, or load
failed”, save is fire-and-forget. The AutoRefresh state machine
always validates freshness via Token::is_usable / Token::is_expired
before returning a loaded token, so implementations don’t need to.
On native targets the trait carries Send + Sync bounds so the store can
be shared across tokio::spawn background work. On wasm32 the bounds are
dropped — edge runtimes are single-threaded.
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl<T: TokenStore + ?Sized> TokenStore for Arc<T>
Available on non-WebAssembly only.Forward TokenStore through Arc so one store can back many strategy
instances (Edge Function pool, CipherStash Proxy worker pool, etc).
impl<T: TokenStore + ?Sized> TokenStore for Arc<T>
Forward TokenStore through Arc so one store can back many strategy
instances (Edge Function pool, CipherStash Proxy worker pool, etc).