pub struct TokenCache { /* private fields */ }Expand description
TokenCache provides secure persistence of OAuth tokens between application runs
Implementations§
Source§impl TokenCache
impl TokenCache
Sourcepub fn new(config: TokenCacheConfig) -> Result<Self, GmailApiError>
pub fn new(config: TokenCacheConfig) -> Result<Self, GmailApiError>
Create a new TokenCache with the provided configuration
Sourcepub fn save_token(
&self,
access_token: &str,
refresh_token: &str,
expiry: SystemTime,
) -> GmailResult<()>
pub fn save_token( &self, access_token: &str, refresh_token: &str, expiry: SystemTime, ) -> GmailResult<()>
Save token to the cache file
Sourcepub fn load_token(&self) -> GmailResult<Option<CachedToken>>
pub fn load_token(&self) -> GmailResult<Option<CachedToken>>
Load token from the cache file
Sourcepub fn is_token_valid(&self, token: &CachedToken) -> bool
pub fn is_token_valid(&self, token: &CachedToken) -> bool
Check if the token is still valid
Sourcepub fn clear_cache(&self) -> GmailResult<()>
pub fn clear_cache(&self) -> GmailResult<()>
Delete the token cache file
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 moreAuto 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