pub struct TokenCache { /* private fields */ }Expand description
Thread-safe, per-provider cache of broker access tokens. Cloneable handle over shared state. Holds ONLY short-lived access tokens, never a refresh token, never persisted to disk.
Implementations§
Source§impl TokenCache
impl TokenCache
pub fn new() -> Self
Sourcepub fn get_fresh(&self, provider: &str, margin_ms: u64) -> Option<BrokerToken>
pub fn get_fresh(&self, provider: &str, margin_ms: u64) -> Option<BrokerToken>
Return the cached token for provider only if present AND not within
margin_ms of expiry. Otherwise None (caller should fetch).
pub fn put(&self, provider: &str, token: BrokerToken)
pub fn invalidate(&self, provider: &str)
Sourcepub fn get_unexpired(&self, provider: &str) -> Option<BrokerToken>
pub fn get_unexpired(&self, provider: &str) -> Option<BrokerToken>
Cached token if present and not PAST hard expiry (ignores the refetch margin). Used as a degraded-mode fallback when the broker is unreachable: a token slightly inside its refetch window is still better than failing.
Trait Implementations§
Source§impl Clone for TokenCache
impl Clone for TokenCache
Source§fn clone(&self) -> TokenCache
fn clone(&self) -> TokenCache
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TokenCache
Redacting Debug — print only the cached provider names, never the tokens.
impl Debug for TokenCache
Redacting Debug — print only the cached provider names, never the tokens.
Source§impl Default for TokenCache
impl Default for TokenCache
Source§fn default() -> TokenCache
fn default() -> TokenCache
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for TokenCache
impl RefUnwindSafe for TokenCache
impl Send for TokenCache
impl Sync for TokenCache
impl Unpin for TokenCache
impl UnsafeUnpin for TokenCache
impl UnwindSafe for TokenCache
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more