actix_session::storage

Trait SessionStore

Source
pub trait SessionStore {
    // Required methods
    fn load(
        &self,
        session_key: &SessionKey,
    ) -> impl Future<Output = Result<Option<HashMap<String, String>>, LoadError>>;
    fn save(
        &self,
        session_state: HashMap<String, String>,
        ttl: &Duration,
    ) -> impl Future<Output = Result<SessionKey, SaveError>>;
    fn update(
        &self,
        session_key: SessionKey,
        session_state: HashMap<String, String>,
        ttl: &Duration,
    ) -> impl Future<Output = Result<SessionKey, UpdateError>>;
    fn update_ttl(
        &self,
        session_key: &SessionKey,
        ttl: &Duration,
    ) -> impl Future<Output = Result<(), Error>>;
    fn delete(
        &self,
        session_key: &SessionKey,
    ) -> impl Future<Output = Result<(), Error>>;
}
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.

Required Methods§

Source

fn load( &self, session_key: &SessionKey, ) -> impl Future<Output = Result<Option<HashMap<String, String>>, LoadError>>

Loads the session state associated to a session key.

Source

fn save( &self, session_state: HashMap<String, String>, ttl: &Duration, ) -> impl Future<Output = Result<SessionKey, SaveError>>

Persist the session state for a newly created session.

Returns the corresponding session key.

Source

fn update( &self, session_key: SessionKey, session_state: HashMap<String, String>, ttl: &Duration, ) -> impl Future<Output = Result<SessionKey, UpdateError>>

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

Source

fn update_ttl( &self, session_key: &SessionKey, ttl: &Duration, ) -> impl Future<Output = Result<(), Error>>

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

Source

fn delete( &self, session_key: &SessionKey, ) -> impl Future<Output = Result<(), Error>>

Deletes a session from the store.

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§