pub struct TokenEndpointCache(/* private fields */);Expand description
Thread-safe token cache for Auth::TokenEndpoint.
Implementations§
Source§impl TokenEndpointCache
impl TokenEndpointCache
pub fn new() -> Self
Sourcepub async fn invalidate(&self)
pub async fn invalidate(&self)
Drop any cached token so the next get_or_refresh
fetches a fresh one. Called when the API rejects the current token with a
401 — a server-side expiry the time-based is_valid check cannot detect
(F57).
Sourcepub async fn get_or_refresh(
&self,
client: &Client,
url: &str,
method: &Method,
headers: &HeaderMap,
body: Option<&Value>,
token_path: &str,
expiry_path: Option<&str>,
expiry_ratio: f64,
response_validator: Option<&ResponseValidator>,
) -> Result<String, FaucetError>
pub async fn get_or_refresh( &self, client: &Client, url: &str, method: &Method, headers: &HeaderMap, body: Option<&Value>, token_path: &str, expiry_path: Option<&str>, expiry_ratio: f64, response_validator: Option<&ResponseValidator>, ) -> Result<String, FaucetError>
Return a valid cached token or fetch a new one from the endpoint.
Trait Implementations§
Source§impl Clone for TokenEndpointCache
impl Clone for TokenEndpointCache
Source§fn clone(&self) -> TokenEndpointCache
fn clone(&self) -> TokenEndpointCache
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 TokenEndpointCache
impl Debug for TokenEndpointCache
Source§impl Default for TokenEndpointCache
impl Default for TokenEndpointCache
Source§fn default() -> TokenEndpointCache
fn default() -> TokenEndpointCache
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !RefUnwindSafe for TokenEndpointCache
impl !UnwindSafe for TokenEndpointCache
impl Freeze for TokenEndpointCache
impl Send for TokenEndpointCache
impl Sync for TokenEndpointCache
impl Unpin for TokenEndpointCache
impl UnsafeUnpin for TokenEndpointCache
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