pub trait OAuth2AccessTokenRepository: Send + Sync {
    type Error;
    // Required methods
    fn lookup<'life0, 'async_trait>(
        &'life0 mut self,
        id: Ulid,
    ) -> Pin<Box<dyn Future<Output = Result<Option<AccessToken>, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn find_by_token<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        access_token: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<AccessToken>, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn add<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 mut self,
        rng: &'life1 mut (dyn RngCore + Send),
        clock: &'life2 dyn Clock,
        session: &'life3 Session,
        access_token: String,
        expires_after: Option<Duration>,
    ) -> Pin<Box<dyn Future<Output = Result<AccessToken, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
    fn revoke<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        clock: &'life1 dyn Clock,
        access_token: AccessToken,
    ) -> Pin<Box<dyn Future<Output = Result<AccessToken, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn mark_used<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        clock: &'life1 dyn Clock,
        access_token: AccessToken,
    ) -> Pin<Box<dyn Future<Output = Result<AccessToken, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn cleanup_revoked<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        clock: &'life1 dyn Clock,
    ) -> Pin<Box<dyn Future<Output = Result<usize, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}Expand description
An OAuth2AccessTokenRepository helps interacting with [AccessToken]
saved in the storage backend
Required Associated Types§
Required Methods§
sourcefn lookup<'life0, 'async_trait>(
    &'life0 mut self,
    id: Ulid,
) -> Pin<Box<dyn Future<Output = Result<Option<AccessToken>, Self::Error>> + Send + 'async_trait>>where
    Self: 'async_trait,
    'life0: 'async_trait,
 
fn lookup<'life0, 'async_trait>(
    &'life0 mut self,
    id: Ulid,
) -> Pin<Box<dyn Future<Output = Result<Option<AccessToken>, Self::Error>> + Send + 'async_trait>>where
    Self: 'async_trait,
    'life0: 'async_trait,
Lookup an access token by its ID
Returns the access token if it exists, None otherwise
§Parameters
- id: The ID of the access token to lookup
§Errors
Returns Self::Error if the underlying repository fails
sourcefn find_by_token<'life0, 'life1, 'async_trait>(
    &'life0 mut self,
    access_token: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<AccessToken>, Self::Error>> + Send + 'async_trait>>where
    Self: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,
 
fn find_by_token<'life0, 'life1, 'async_trait>(
    &'life0 mut self,
    access_token: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<AccessToken>, Self::Error>> + Send + 'async_trait>>where
    Self: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,
Find an access token by its token
Returns the access token if it exists, None otherwise
§Parameters
- access_token: The token of the access token to lookup
§Errors
Returns Self::Error if the underlying repository fails
sourcefn add<'life0, 'life1, 'life2, 'life3, 'async_trait>(
    &'life0 mut self,
    rng: &'life1 mut (dyn RngCore + Send),
    clock: &'life2 dyn Clock,
    session: &'life3 Session,
    access_token: String,
    expires_after: Option<Duration>,
) -> Pin<Box<dyn Future<Output = Result<AccessToken, Self::Error>> + Send + 'async_trait>>where
    Self: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    'life3: 'async_trait,
 
fn add<'life0, 'life1, 'life2, 'life3, 'async_trait>(
    &'life0 mut self,
    rng: &'life1 mut (dyn RngCore + Send),
    clock: &'life2 dyn Clock,
    session: &'life3 Session,
    access_token: String,
    expires_after: Option<Duration>,
) -> Pin<Box<dyn Future<Output = Result<AccessToken, Self::Error>> + Send + 'async_trait>>where
    Self: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    'life3: 'async_trait,
Add a new access token to the database
Returns the newly created access token
§Parameters
- rng: A random number generator
- clock: The clock used to generate timestamps
- session: The session the access token is associated with
- access_token: The access token to add
- expires_after: The duration after which the access token expires. If- Nonethe access token never expires
§Errors
Returns Self::Error if the underlying repository fails
sourcefn revoke<'life0, 'life1, 'async_trait>(
    &'life0 mut self,
    clock: &'life1 dyn Clock,
    access_token: AccessToken,
) -> Pin<Box<dyn Future<Output = Result<AccessToken, Self::Error>> + Send + 'async_trait>>where
    Self: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,
 
fn revoke<'life0, 'life1, 'async_trait>(
    &'life0 mut self,
    clock: &'life1 dyn Clock,
    access_token: AccessToken,
) -> Pin<Box<dyn Future<Output = Result<AccessToken, Self::Error>> + Send + 'async_trait>>where
    Self: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,
Revoke an access token
Returns the revoked access token
§Parameters
- clock: The clock used to generate timestamps
- access_token: The access token to revoke
§Errors
Returns Self::Error if the underlying repository fails
sourcefn mark_used<'life0, 'life1, 'async_trait>(
    &'life0 mut self,
    clock: &'life1 dyn Clock,
    access_token: AccessToken,
) -> Pin<Box<dyn Future<Output = Result<AccessToken, Self::Error>> + Send + 'async_trait>>where
    Self: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,
 
fn mark_used<'life0, 'life1, 'async_trait>(
    &'life0 mut self,
    clock: &'life1 dyn Clock,
    access_token: AccessToken,
) -> Pin<Box<dyn Future<Output = Result<AccessToken, Self::Error>> + Send + 'async_trait>>where
    Self: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,
Mark the access token as used, to track when it was first used
§Parameters
- clock: The clock used to generate timestamps
- access_token: The access token to mark as used
§Errors
Returns Self::Error if the underlying repository fails
sourcefn cleanup_revoked<'life0, 'life1, 'async_trait>(
    &'life0 mut self,
    clock: &'life1 dyn Clock,
) -> Pin<Box<dyn Future<Output = Result<usize, Self::Error>> + Send + 'async_trait>>where
    Self: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,
 
fn cleanup_revoked<'life0, 'life1, 'async_trait>(
    &'life0 mut self,
    clock: &'life1 dyn Clock,
) -> Pin<Box<dyn Future<Output = Result<usize, Self::Error>> + Send + 'async_trait>>where
    Self: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,
Cleanup revoked access tokens
Returns the number of access tokens that were cleaned up
§Parameters
- clock: The clock used to get the current time
§Errors
Returns Self::Error if the underlying repository fails