Skip to main content

AnySessionMethod

Trait AnySessionMethod 

Source
pub trait AnySessionMethod:
    AnyExt
    + DatabaseConsumer
    + Serialize
    + Deserialize {
    // Required methods
    fn check<'life0, 'async_trait>(
        &'life0 self,
        db_conns: DbConns,
        token: CompactString,
    ) -> Pin<Box<dyn Future<Output = Result<Option<UserId>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn new<'life0, 'async_trait>(
        &'life0 self,
        db_conns: DbConns,
        user_id: UserId,
    ) -> Pin<Box<dyn Future<Output = Result<CompactString>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn invalidate<'life0, 'async_trait>(
        &'life0 self,
        db_conns: DbConns,
        user_id: UserId,
        token: Option<CompactString>,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn remove_expired<'life0, 'async_trait>(
        &'life0 self,
        db_conn: Arc<dyn AnyDatabaseConnection>,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn max_age(&self) -> Option<usize> { ... }
}
Expand description

Trait implemented for every session’s storage backend.

Required Methods§

Source

fn check<'life0, 'async_trait>( &'life0 self, db_conns: DbConns, token: CompactString, ) -> Pin<Box<dyn Future<Output = Result<Option<UserId>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get whether a user is authenticated by the given session token.

Source

fn new<'life0, 'async_trait>( &'life0 self, db_conns: DbConns, user_id: UserId, ) -> Pin<Box<dyn Future<Output = Result<CompactString>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Create a new session for the given user.

Source

fn invalidate<'life0, 'async_trait>( &'life0 self, db_conns: DbConns, user_id: UserId, token: Option<CompactString>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Invalidate all session’s of the given user.

Source

fn remove_expired<'life0, 'async_trait>( &'life0 self, db_conn: Arc<dyn AnyDatabaseConnection>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Remove all the expired sessions.

Provided Methods§

Source

fn max_age(&self) -> Option<usize>

Trait Implementations§

Source§

impl<'typetag> Serialize for dyn AnySessionMethod + 'typetag

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<'typetag> Serialize for dyn AnySessionMethod + Send + 'typetag

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<'typetag> Serialize for dyn AnySessionMethod + Sync + 'typetag

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<'typetag> Serialize for dyn AnySessionMethod + Send + Sync + 'typetag

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§