Trait SessionStore

Source
pub trait SessionStore:
    Debug
    + Send
    + Sync
    + 'static {
    // Required methods
    fn save<'life0, 'life1, 'async_trait>(
        &'life0 self,
        session_record: &'life1 Record,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn load<'life0, 'life1, 'async_trait>(
        &'life0 self,
        session_id: &'life1 Id,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Record>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn delete<'life0, 'life1, 'async_trait>(
        &'life0 self,
        session_id: &'life1 Id,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided method
    fn create<'life0, 'life1, 'async_trait>(
        &'life0 self,
        session_record: &'life1 mut Record,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

Defines the interface for session management.

See session_store for more details.

Required Methods§

Source

fn save<'life0, 'life1, 'async_trait>( &'life0 self, session_record: &'life1 Record, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Saves the provided session record to the store.

This method is intended for updating the state of an existing session.

Source

fn load<'life0, 'life1, 'async_trait>( &'life0 self, session_id: &'life1 Id, ) -> Pin<Box<dyn Future<Output = Result<Option<Record>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Loads an existing session record from the store using the provided ID.

If a session with the given ID exists, it is returned. If the session does not exist or has been invalidated (e.g., expired), None is returned.

Source

fn delete<'life0, 'life1, 'async_trait>( &'life0 self, session_id: &'life1 Id, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Deletes a session record from the store using the provided ID.

If the session exists, it is removed from the store.

Provided Methods§

Source

fn create<'life0, 'life1, 'async_trait>( &'life0 self, session_record: &'life1 mut Record, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Creates a new session in the store with the provided session record.

Implementers must decide how to handle potential ID collisions. For example, they might generate a new unique ID or return Error::Backend.

The record is given as an exclusive reference to allow modifications, such as assigning a new ID, during the creation process.

Implementors§

Source§

impl<Cache, Store> SessionStore for CachingSessionStore<Cache, Store>
where Cache: SessionStore, Store: SessionStore,