logo
pub trait SessionStore {
    fn load<'life0, 'life1, 'async_trait>(
        &'life0 self,
        session_key: &'life1 SessionKey
    ) -> Pin<Box<dyn Future<Output = Result<Option<HashMap<String, String>>, LoadError>> + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
; fn save<'life0, 'life1, 'async_trait>(
        &'life0 self,
        session_state: HashMap<String, String>,
        ttl: &'life1 Duration
    ) -> Pin<Box<dyn Future<Output = Result<SessionKey, SaveError>> + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
; fn update<'life0, 'life1, 'async_trait>(
        &'life0 self,
        session_key: SessionKey,
        session_state: HashMap<String, String>,
        ttl: &'life1 Duration
    ) -> Pin<Box<dyn Future<Output = Result<SessionKey, UpdateError>> + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
; fn update_ttl<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        session_key: &'life1 SessionKey,
        ttl: &'life2 Duration
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        'life2: 'async_trait,
        Self: 'async_trait
; fn delete<'life0, 'life1, 'async_trait>(
        &'life0 self,
        session_key: &'life1 SessionKey
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
; }
Expand description

The interface to retrieve and save the current session data from/to the chosen storage backend.

You can provide your own custom session store backend by implementing this trait.

async-trait is used for this trait’s definition. Therefore, it is required for implementations, too. In particular, we use the send-optional variant: #[async_trait(?Send)].

Required Methods

Loads the session state associated to a session key.

Persist the session state for a newly created session.

Returns the corresponding session key.

Updates the session state associated to a pre-existing session key.

Updates the TTL of the session state associated to a pre-existing session key.

Deletes a session from the store.

Implementors