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
        Self: 'async_trait,
        'life0: 'async_trait,
        'life1: '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
        Self: 'async_trait,
        'life0: 'async_trait,
        'life1: '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
        Self: 'async_trait,
        'life0: 'async_trait,
        'life1: '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
        Self: 'async_trait,
        'life0: 'async_trait,
        'life1: 'async_trait,
        'life2: 'async_trait
; fn delete<'life0, 'life1, 'async_trait>(
        &'life0 self,
        session_key: &'life1 SessionKey
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>>
    where
        Self: 'async_trait,
        'life0: 'async_trait,
        'life1: '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§

source

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
    Self: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,

Loads the session state associated to a session key.

source

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
    Self: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,

Persist the session state for a newly created session.

Returns the corresponding session key.

source

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
    Self: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,

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

source

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
    Self: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,

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

source

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

Deletes a session from the store.

Implementors§