pub struct SessionManager { /* private fields */ }Expand description
Orchestrates session lifecycle: cookie extraction, store lookup, creation, persistence, and deletion.
Not #[Injectable] — provide via ctx.provide(SessionManager::new(...)).
Implementations§
Source§impl SessionManager
impl SessionManager
pub fn new(store: impl SessionStore, config: SessionConfig) -> Self
Sourcepub async fn load_from_headers(
&self,
headers: &HeaderMap,
) -> Option<Arc<Session>>
pub async fn load_from_headers( &self, headers: &HeaderMap, ) -> Option<Arc<Session>>
Reads and verifies the session-ID cookie, then loads the session from
the store. Returns None if the cookie is missing, tampered, or the
session has expired / been deleted.
Sourcepub async fn create(&self) -> Arc<Session> ⓘ
pub async fn create(&self) -> Arc<Session> ⓘ
Create a new empty session (not yet persisted — call save after
populating data).
Sourcepub async fn save(&self, session: &Session) -> bool
pub async fn save(&self, session: &Session) -> bool
Persist session to the store with the configured TTL.
Sourcepub async fn delete(&self, id: &str) -> bool
pub async fn delete(&self, id: &str) -> bool
Delete session from the store (logout / invalidation).
Returns a Set-Cookie header value that sets the session-ID cookie.
Returns a Set-Cookie header value that clears the session-ID cookie.
Hot-swap the session-cookie HMAC secret (delegates to the internal
CookieService; previous secret stays valid for the grace window).
Auto Trait Implementations§
impl !Freeze for SessionManager
impl !RefUnwindSafe for SessionManager
impl !UnwindSafe 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request