Skip to main content

SessionStore

Trait SessionStore 

Source
pub trait SessionStore:
    Send
    + Sync
    + 'static {
    // Required methods
    fn load(
        &self,
        id: &str,
    ) -> impl Future<Output = Result<Option<HashMap<String, String>>, SessionStoreError>> + Send;
    fn save(
        &self,
        id: &str,
        data: HashMap<String, String>,
    ) -> impl Future<Output = Result<(), SessionStoreError>> + Send;
    fn destroy(
        &self,
        id: &str,
    ) -> impl Future<Output = Result<(), SessionStoreError>> + Send;
}
Expand description

Pluggable session storage backend.

Implement this trait to store sessions in Redis, a database, etc. The default implementation is MemoryStore.

Required Methods§

Source

fn load( &self, id: &str, ) -> impl Future<Output = Result<Option<HashMap<String, String>>, SessionStoreError>> + Send

Load session data for the given ID. Returns None if the session does not exist or has expired.

Source

fn save( &self, id: &str, data: HashMap<String, String>, ) -> impl Future<Output = Result<(), SessionStoreError>> + Send

Save session data under the given ID.

Source

fn destroy( &self, id: &str, ) -> impl Future<Output = Result<(), SessionStoreError>> + Send

Delete session data for the given ID.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§