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§
Sourcefn load(
&self,
session_key: &SessionKey,
) -> impl Future<Output = Result<Option<HashMap<String, String>>, LoadError>>
fn load( &self, session_key: &SessionKey, ) -> impl Future<Output = Result<Option<HashMap<String, String>>, LoadError>>
Loads the session state associated to a session key.
Sourcefn save(
&self,
session_state: HashMap<String, String>,
ttl: &Duration,
) -> impl Future<Output = Result<SessionKey, SaveError>>
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.
Sourcefn update(
&self,
session_key: SessionKey,
session_state: HashMap<String, String>,
ttl: &Duration,
) -> impl Future<Output = Result<SessionKey, UpdateError>>
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.
Sourcefn update_ttl(
&self,
session_key: &SessionKey,
ttl: &Duration,
) -> impl Future<Output = Result<(), Error>>
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.
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§
impl SessionStore for CookieSessionStore
Available on crate feature
cookie-session only.impl SessionStore for RedisSessionStore
Available on crate feature
redis-session only.