pub struct SessionManager { /* private fields */ }Expand description
Session manager
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 builder() -> SessionManagerBuilder
pub fn builder() -> SessionManagerBuilder
Create a builder
Sourcepub fn create_session(
&self,
identity: Identity,
client_ip: Option<IpAddr>,
user_agent: Option<String>,
) -> Result<Session, SessionError>
pub fn create_session( &self, identity: Identity, client_ip: Option<IpAddr>, user_agent: Option<String>, ) -> Result<Session, SessionError>
Create a new session
Sourcepub fn get_session(&self, token: &str) -> Result<Session, SessionError>
pub fn get_session(&self, token: &str) -> Result<Session, SessionError>
Get session by token
Sourcepub fn get_session_by_id(
&self,
session_id: &str,
) -> Result<Session, SessionError>
pub fn get_session_by_id( &self, session_id: &str, ) -> Result<Session, SessionError>
Get session by ID
Sourcepub fn validate_token(&self, token: &str) -> Result<Identity, SessionError>
pub fn validate_token(&self, token: &str) -> Result<Identity, SessionError>
Validate token and return identity
Sourcepub fn refresh_session(&self, token: &str) -> Result<Session, SessionError>
pub fn refresh_session(&self, token: &str) -> Result<Session, SessionError>
Refresh session (extend expiration)
Sourcepub fn invalidate_session(&self, token: &str) -> Result<(), SessionError>
pub fn invalidate_session(&self, token: &str) -> Result<(), SessionError>
Invalidate a session
Sourcepub fn invalidate_session_by_id(
&self,
session_id: &str,
) -> Result<(), SessionError>
pub fn invalidate_session_by_id( &self, session_id: &str, ) -> Result<(), SessionError>
Invalidate session by ID
Sourcepub fn invalidate_user_sessions(&self, user_id: &str)
pub fn invalidate_user_sessions(&self, user_id: &str)
Invalidate all sessions for a user
Sourcepub fn list_user_sessions(&self, user_id: &str) -> Vec<Session>
pub fn list_user_sessions(&self, user_id: &str) -> Vec<Session>
List all sessions for a user
Sourcepub fn update_metadata(
&self,
token: &str,
key: impl Into<String>,
value: impl Into<String>,
) -> Result<(), SessionError>
pub fn update_metadata( &self, token: &str, key: impl Into<String>, value: impl Into<String>, ) -> Result<(), SessionError>
Update session metadata
Sourcepub fn stats(&self) -> SessionStats
pub fn stats(&self) -> 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 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
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