pub struct SessionManager { /* private fields */ }Expand description
The application’s session store and settings.
This is what the container holds and what the Session facade resolves.
It is not a request’s session. A facade is process-global and a session
belongs to one request, so there is nothing honest for
Session::instance().get("user_id") to return. Per-request access is
request.session(); this type is for
the operations that genuinely are application-wide — reading or destroying
a session by id, and collecting expired ones.
Implementations§
Source§impl SessionManager
impl SessionManager
Sourcepub fn new(store: Arc<dyn SessionStore>) -> SessionManager
pub fn new(store: Arc<dyn SessionStore>) -> SessionManager
A manager over store, with the default cookie settings.
Sourcepub fn with_config(
store: Arc<dyn SessionStore>,
config: SessionConfig,
) -> SessionManager
pub fn with_config( store: Arc<dyn SessionStore>, config: SessionConfig, ) -> SessionManager
A manager with explicit settings.
Sourcepub fn configure(
self,
adjust: impl FnOnce(SessionConfig) -> SessionConfig,
) -> SessionManager
pub fn configure( self, adjust: impl FnOnce(SessionConfig) -> SessionConfig, ) -> SessionManager
Adjust the settings.
Sourcepub fn store(&self) -> &Arc<dyn SessionStore> ⓘ
pub fn store(&self) -> &Arc<dyn SessionStore> ⓘ
The store.
Sourcepub fn config(&self) -> &SessionConfig
pub fn config(&self) -> &SessionConfig
The cookie settings.
Sourcepub async fn read(&self, id: &str) -> Result<Option<SessionData>, Error>
pub async fn read(&self, id: &str) -> Result<Option<SessionData>, Error>
Read a session by id, without a request.
For an administrative view: “what is in this user’s session”.
Trait Implementations§
Source§impl Clone for SessionManager
impl Clone for SessionManager
Source§fn clone(&self) -> SessionManager
fn clone(&self) -> SessionManager
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for SessionManager
impl !UnwindSafe for SessionManager
impl Freeze for SessionManager
impl Send for SessionManager
impl Sync for SessionManager
impl Unpin for SessionManager
impl UnsafeUnpin for SessionManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Event for T
impl<T> Event for T
Source§fn event_name() -> &'static strwhere
Self: Sized,
fn event_name() -> &'static strwhere
Self: Sized,
A human-readable name, used by wildcard listeners and log output.
Always the Rust type path; see the trait docs.
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.