pub struct SessionPlugin { /* private fields */ }Expand description
Process-wide SessionPlugin singleton storing SessionConfig and a pluggable SessionStore.
Implementations§
Source§impl SessionPlugin
Inherent implementation of SessionPlugin.
impl SessionPlugin
Inherent implementation of SessionPlugin.
Sourcepub fn init(config: SessionConfig) -> &'static Self
pub fn init(config: SessionConfig) -> &'static Self
Initializes the global SessionPlugin once with config and the default InMemorySessionStore.
§Arguments
SessionConfig- Cookie and session policy.
§Returns
&'static Self- Reference to the initialized global plugin.
Sourcepub fn init_with_store(
config: SessionConfig,
store: SharedSessionStore,
) -> &'static Self
pub fn init_with_store( config: SessionConfig, store: SharedSessionStore, ) -> &'static Self
Initializes the global SessionPlugin once with config and a custom SessionStore.
§Arguments
SessionConfig- Cookie and session policy.SharedSessionStore- Pluggable session store backend.
§Returns
&'static Self- Reference to the initialized global plugin.
Sourcepub fn get() -> Option<&'static Self>
pub fn get() -> Option<&'static Self>
Returns the initialized global SessionPlugin, if initialized.
§Returns
Option<&'static Self>- Reference to the global plugin, orNone.
Sourcepub fn get_config(&self) -> &SessionConfig
pub fn get_config(&self) -> &SessionConfig
Sourcepub fn get_store(&self) -> &SharedSessionStore
pub fn get_store(&self) -> &SharedSessionStore
Sourcepub fn current(ctx: &Context) -> Option<SessionHandle>
pub fn current(ctx: &Context) -> Option<SessionHandle>
Retrieves the active SessionHandle stored in ctx.
§Arguments
&Context- Request context.
§Returns
Option<SessionHandle>- Per-request session handle, if session middleware ran.
Sourcepub async fn load_into_context(&self, ctx: &mut Context) -> SessionHandle
pub async fn load_into_context(&self, ctx: &mut Context) -> SessionHandle
Loads or initializes the SessionHandle on ctx from the incoming Cookie header.
§Arguments
&mut Context- Incoming request context.
§Returns
SessionHandle- Active session handle attached toctx.
Sourcepub async fn persist_from_context(&self, ctx: &mut Context)
pub async fn persist_from_context(&self, ctx: &mut Context)
Persists dirty, regenerated, or destroyed session state and emits Set-Cookie on ctx.
§Arguments
&mut Context- Outgoing request/response context.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for SessionPlugin
impl !UnwindSafe for SessionPlugin
impl Forget for SessionPlugin
impl Freeze for SessionPluginwhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
*const ArcInner<dyn SessionStore> is !null: Freeze,
PhantomData<ArcInner<dyn SessionStore>>: Freeze,
*const ArcInner<SessionCompiled> is !null: Freeze,
PhantomData<ArcInner<SessionCompiled>>: Freeze,
*const ArcInner<InMemorySessionStoreInner> is !null: Freeze,
PhantomData<ArcInner<InMemorySessionStoreInner>>: Freeze,
impl Move for SessionPlugin
impl Send for SessionPlugin
impl Sync for SessionPlugin
impl Unpin for SessionPlugin
impl UnsafeUnpin for SessionPluginwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
*const ArcInner<dyn SessionStore> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn SessionStore>>: UnsafeUnpin,
*const ArcInner<SessionCompiled> is !null: UnsafeUnpin,
PhantomData<ArcInner<SessionCompiled>>: UnsafeUnpin,
*const ArcInner<InMemorySessionStoreInner> is !null: UnsafeUnpin,
PhantomData<ArcInner<InMemorySessionStoreInner>>: UnsafeUnpin,
Blanket Implementations§
impl<T> AnySend for T
impl<T> AnySendClone for T
impl<T> AnySendSync for T
impl<T> AnySendSyncClone for T
impl<T> AnySync for T
impl<T> AnySyncClone for T
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