Struct typed_session::SessionStore
source · 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.
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, CookieGenerator> SessionStore<SessionData, SessionStoreConnection, CookieGenerator>
impl<SessionData, SessionStoreConnection, CookieGenerator> SessionStore<SessionData, SessionStoreConnection, CookieGenerator>
sourcepub fn into_inner(self) -> SessionStoreConnection
pub fn into_inner(self) -> SessionStoreConnection
Consume the SessionStore and return the wrapped SessionStoreConnection.
source§impl<SessionData, SessionStoreConnection> SessionStore<SessionData, SessionStoreConnection, DefaultSessionCookieGenerator>
impl<SessionData, SessionStoreConnection> SessionStore<SessionData, SessionStoreConnection, DefaultSessionCookieGenerator>
sourcepub fn new(
implementation: SessionStoreConnection,
expiry_strategy: SessionRenewalStrategy
) -> Self
pub fn new( implementation: SessionStoreConnection, expiry_strategy: SessionRenewalStrategy ) -> Self
Create a new session store with the given implementation, 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 implementation, 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>
) -> Result<SessionCookieCommand>
pub async fn store_session( &self, session: Session<SessionData> ) -> Result<SessionCookieCommand>
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) -> Result
pub async fn clear_store(&self) -> Result
Empties the entire store, deleting all sessions.
source§impl<SessionData: Debug, SessionStoreConnection: SessionStoreConnector<SessionData>, CookieGenerator> SessionStore<SessionData, SessionStoreConnection, CookieGenerator>
impl<SessionData: Debug, SessionStoreConnection: SessionStoreConnector<SessionData>, CookieGenerator> SessionStore<SessionData, SessionStoreConnection, CookieGenerator>
sourcepub async fn load_session(
&self,
cookie_value: impl AsRef<str>
) -> Result<Option<Session<SessionData>>>
pub async fn load_session( &self, cookie_value: impl AsRef<str> ) -> Result<Option<Session<SessionData>>>
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.