Struct 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.

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>

Source

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>

Create a new session store with the given cookie generator and session renewal strategy.

Source

pub fn session_renewal_strategy(&self) -> &SessionRenewalStrategy

A reference to the session renewal strategy of this session store.

Source

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>

Source

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.

Source

pub async fn clear_store( &self, connection: &mut SessionStoreConnection, ) -> Result<(), Error<SessionStoreConnection::Error>>

Empties the entire store, deleting all sessions.

Source

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.

Trait Implementations§

Source§

impl<SessionData, SessionStoreConnection, CookieGenerator: Clone> Clone for SessionStore<SessionData, SessionStoreConnection, CookieGenerator>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<SessionData: Debug, SessionStoreConnection: Debug, CookieGenerator: Debug> Debug for SessionStore<SessionData, SessionStoreConnection, CookieGenerator>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<SessionData, SessionStoreConnection, CookieGenerator> Freeze for SessionStore<SessionData, SessionStoreConnection, CookieGenerator>
where CookieGenerator: Freeze,

§

impl<SessionData, SessionStoreConnection, CookieGenerator> RefUnwindSafe for SessionStore<SessionData, SessionStoreConnection, CookieGenerator>
where CookieGenerator: RefUnwindSafe, SessionData: RefUnwindSafe, SessionStoreConnection: RefUnwindSafe,

§

impl<SessionData, SessionStoreConnection, CookieGenerator> Send for SessionStore<SessionData, SessionStoreConnection, CookieGenerator>
where CookieGenerator: Send, SessionData: Send, SessionStoreConnection: Send,

§

impl<SessionData, SessionStoreConnection, CookieGenerator> Sync for SessionStore<SessionData, SessionStoreConnection, CookieGenerator>
where CookieGenerator: Sync, SessionData: Sync, SessionStoreConnection: Sync,

§

impl<SessionData, SessionStoreConnection, CookieGenerator> Unpin for SessionStore<SessionData, SessionStoreConnection, CookieGenerator>
where CookieGenerator: Unpin, SessionData: Unpin, SessionStoreConnection: Unpin,

§

impl<SessionData, SessionStoreConnection, CookieGenerator> UnwindSafe for SessionStore<SessionData, SessionStoreConnection, CookieGenerator>
where CookieGenerator: UnwindSafe, SessionData: UnwindSafe, SessionStoreConnection: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more