pub struct SessionManager { /* private fields */ }Expand description
Thread-safe session manager — stores all active sessions.
Implementations§
Source§impl SessionManager
impl SessionManager
Sourcepub fn new(config: SessionConfig) -> Self
pub fn new(config: SessionConfig) -> Self
Create a new session manager.
Sourcepub fn get_or_create(&self, session_id: &str) -> String
pub fn get_or_create(&self, session_id: &str) -> String
Get or create a session context.
Sourcepub fn with_session<F, R>(&self, session_id: &str, f: F) -> Option<R>where
F: FnOnce(&mut SessionContext) -> R,
pub fn with_session<F, R>(&self, session_id: &str, f: F) -> Option<R>where
F: FnOnce(&mut SessionContext) -> R,
Execute a function with mutable access to a session.
Sourcepub fn with_session_ref<F, R>(&self, session_id: &str, f: F) -> Option<R>where
F: FnOnce(&SessionContext) -> R,
pub fn with_session_ref<F, R>(&self, session_id: &str, f: F) -> Option<R>where
F: FnOnce(&SessionContext) -> R,
Execute a function with read access to a session.
Sourcepub fn list_sessions(&self) -> Vec<SessionStats>
pub fn list_sessions(&self) -> Vec<SessionStats>
List all active sessions (stats only, no PII).
Sourcepub fn inspect(&self, session_id: &str) -> Option<SessionStats>
pub fn inspect(&self, session_id: &str) -> Option<SessionStats>
Inspect a specific session (stats only).
Sourcepub fn flush_session(&self, session_id: &str) -> bool
pub fn flush_session(&self, session_id: &str) -> bool
Flush (remove) a specific session.
Sourcepub fn evict_expired(&self) -> usize
pub fn evict_expired(&self) -> usize
Evict expired sessions. Returns number evicted.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Check if session tracking is enabled.
Auto Trait Implementations§
impl !Freeze for SessionManager
impl RefUnwindSafe for SessionManager
impl Send for SessionManager
impl Sync for SessionManager
impl Unpin for SessionManager
impl UnsafeUnpin for SessionManager
impl UnwindSafe 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