# Trait actix_session::storage::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.

## Object Safety§

This trait is not object safe.

## Implementors§

source§

### impl SessionStore for CookieSessionStore

source§

### impl SessionStore for RedisActorSessionStore

source§

### impl SessionStore for RedisSessionStore