pub struct SessionManager { /* private fields */ }Expand description
Session manager for handling session lifecycle
Implementations§
Source§impl SessionManager
impl SessionManager
Sourcepub fn new(config: SessionConfig) -> Self
pub fn new(config: SessionConfig) -> Self
Create new session manager
Sourcepub async fn create_session(
&self,
user_id: &str,
roles: Vec<String>,
permissions: Vec<String>,
ip_address: Option<String>,
user_agent: Option<String>,
) -> Result<SessionData>
pub async fn create_session( &self, user_id: &str, roles: Vec<String>, permissions: Vec<String>, ip_address: Option<String>, user_agent: Option<String>, ) -> Result<SessionData>
Create new session
Sourcepub async fn get_session(&self, session_id: &str) -> Result<Option<SessionData>>
pub async fn get_session(&self, session_id: &str) -> Result<Option<SessionData>>
Get session by ID
Sourcepub async fn update_session(&self, session: SessionData) -> Result<()>
pub async fn update_session(&self, session: SessionData) -> Result<()>
Update session
Sourcepub async fn delete_session(&self, session_id: &str) -> Result<()>
pub async fn delete_session(&self, session_id: &str) -> Result<()>
Delete session
Sourcepub async fn delete_user_sessions(&self, user_id: &str) -> Result<usize>
pub async fn delete_user_sessions(&self, user_id: &str) -> Result<usize>
Delete all sessions for a user
Sourcepub async fn extend_session(
&self,
session_id: &str,
additional_seconds: i64,
) -> Result<()>
pub async fn extend_session( &self, session_id: &str, additional_seconds: i64, ) -> Result<()>
Extend session expiration
Sourcepub async fn validate_session(
&self,
session_id: &str,
) -> Result<Option<SessionData>>
pub async fn validate_session( &self, session_id: &str, ) -> Result<Option<SessionData>>
Validate session and return user information
Sourcepub async fn cleanup_expired_sessions(&self) -> Result<usize>
pub async fn cleanup_expired_sessions(&self) -> Result<usize>
Clean up expired sessions
Sourcepub async fn get_stats(&self) -> Result<SessionStats>
pub async fn get_stats(&self) -> Result<SessionStats>
Get session statistics
Auto Trait Implementations§
impl Freeze for SessionManager
impl !RefUnwindSafe for SessionManager
impl Send for SessionManager
impl Sync for SessionManager
impl Unpin 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
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 more