Skip to main content

TokenRefresher

Trait TokenRefresher 

Source
pub trait TokenRefresher:
    Send
    + Sync
    + 'static {
    // Required method
    fn refresh<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<TokenWithExpiry, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
}
Expand description

Anything which allows to refresh a token.

Default implementations are provided for async functions and closures

Required Methods§

Source

fn refresh<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<TokenWithExpiry, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Refreshes the token and return the new token and its expiry time.

Implementors§

Source§

impl<AsyncFn, FnFuture> TokenRefresher for AsyncFn
where AsyncFn: Fn() -> FnFuture + Send + Sync + 'static, FnFuture: Future<Output = Result<TokenWithExpiry, Box<dyn Error + Send + Sync>>> + Send,

Allow any async function or closure matching the signature to be used as a TokenRefresher.