pub struct SessionStore<SessionData, SessionStoreConnection, CookieGenerator = DefaultSessionCookieGenerator> { /* private fields */ }
Expand description
An async session store.
This is the “front-end” interface of the session store.
Note that most of its methods require passing a connection to the storage backend,
which is of type SessionStoreConnection
.
This is to allow the usage of e.g. an external connection pool without dependence on the session store.
SessionData
is the data associated with a session.
SessionStoreConnection
is the connection to the backend session store.
CookieGenerator
is the type used to generate random session cookies.
Implementations§
Source§impl<SessionData, SessionStoreConnection> SessionStore<SessionData, SessionStoreConnection, DefaultSessionCookieGenerator>
impl<SessionData, SessionStoreConnection> SessionStore<SessionData, SessionStoreConnection, DefaultSessionCookieGenerator>
Sourcepub fn new(expiry_strategy: SessionRenewalStrategy) -> Self
pub fn new(expiry_strategy: SessionRenewalStrategy) -> Self
Create a new session store with the given cookie generator and session renewal strategy.
Source§impl<SessionData, SessionStoreConnection, CookieGenerator> SessionStore<SessionData, SessionStoreConnection, CookieGenerator>
impl<SessionData, SessionStoreConnection, CookieGenerator> SessionStore<SessionData, SessionStoreConnection, CookieGenerator>
Create a new session store with the given cookie generator and session renewal strategy.
Sourcepub fn session_renewal_strategy(&self) -> &SessionRenewalStrategy
pub fn session_renewal_strategy(&self) -> &SessionRenewalStrategy
A reference to the session renewal strategy of this session store.
Sourcepub fn session_renewal_strategy_mut(&mut self) -> &mut SessionRenewalStrategy
pub fn session_renewal_strategy_mut(&mut self) -> &mut SessionRenewalStrategy
A mutable reference to the session renewal strategy of this session store.
Source§impl<SessionData: Debug, SessionStoreConnection: SessionStoreConnector<SessionData>, CookieGenerator: SessionCookieGenerator> SessionStore<SessionData, SessionStoreConnection, CookieGenerator>
impl<SessionData: Debug, SessionStoreConnection: SessionStoreConnector<SessionData>, CookieGenerator: SessionCookieGenerator> SessionStore<SessionData, SessionStoreConnection, CookieGenerator>
Sourcepub async fn store_session(
&self,
session: Session<SessionData>,
connection: &mut SessionStoreConnection,
) -> Result<SessionCookieCommand, Error<SessionStoreConnection::Error>>
pub async fn store_session( &self, session: Session<SessionData>, connection: &mut SessionStoreConnection, ) -> Result<SessionCookieCommand, Error<SessionStoreConnection::Error>>
Store a session in the storage backend. If the session is marked for deletion, this method deletes the session.
If the session cookie requires to be updated, because the session data or expiry changed, then a SessionCookieCommand is returned.
Sourcepub async fn clear_store(
&self,
connection: &mut SessionStoreConnection,
) -> Result<(), Error<SessionStoreConnection::Error>>
pub async fn clear_store( &self, connection: &mut SessionStoreConnection, ) -> Result<(), Error<SessionStoreConnection::Error>>
Empties the entire store, deleting all sessions.
Sourcepub async fn load_session(
&self,
cookie_value: impl AsRef<str>,
connection: &mut SessionStoreConnection,
) -> Result<Option<Session<SessionData>>, Error<SessionStoreConnection::Error>>
pub async fn load_session( &self, cookie_value: impl AsRef<str>, connection: &mut SessionStoreConnection, ) -> Result<Option<Session<SessionData>>, Error<SessionStoreConnection::Error>>
Get a session from the storage backend.
The cookie_value
is the value of a cookie identifying the session.
The return value is Ok(Some(_))
if there is a session identified by the given cookie that is not expired,
or Ok(None)
if there is no such session that is not expired.