pub struct SessionOperations<'a> { /* private fields */ }Expand description
Focused session-management operations exposed from AuthFramework::sessions.
§Example
// Using the request struct (recommended):
let req = SessionCreateRequest::new("user-123", Duration::from_secs(3600))
.ip_address("10.0.0.1");
let sid = auth.sessions().create_session(req).await?;
// Positional shorthand still works:
let sid = auth.sessions().create("user-123", Duration::from_secs(3600), None, None).await?;
let session = auth.sessions().get(&sid).await?;
auth.sessions().delete(&sid).await?;Implementations§
Source§impl SessionOperations<'_>
impl SessionOperations<'_>
Sourcepub async fn create_session(&self, req: SessionCreateRequest) -> Result<String>
pub async fn create_session(&self, req: SessionCreateRequest) -> Result<String>
Create a new session from a SessionCreateRequest.
This is the preferred entry point — it avoids passing None for
optional parameters and makes the call site self-documenting.
Sourcepub async fn create(
&self,
user_id: &str,
expires_in: Duration,
ip_address: Option<String>,
user_agent: Option<String>,
) -> Result<String>
pub async fn create( &self, user_id: &str, expires_in: Duration, ip_address: Option<String>, user_agent: Option<String>, ) -> Result<String>
Create a new session for a user (positional convenience).
Prefer create_session with a
SessionCreateRequest when you need optional fields.
Sourcepub async fn get(&self, session_id: &str) -> Result<Option<SessionData>>
pub async fn get(&self, session_id: &str) -> Result<Option<SessionData>>
Fetch a session by ID.
Sourcepub async fn list_for_user(&self, user_id: &str) -> Result<Vec<SessionData>>
pub async fn list_for_user(&self, user_id: &str) -> Result<Vec<SessionData>>
List all sessions owned by a user.
Sourcepub async fn list_for_user_filtered(
&self,
user_id: &str,
filter: SessionFilter,
) -> Result<Vec<SessionData>>
pub async fn list_for_user_filtered( &self, user_id: &str, filter: SessionFilter, ) -> Result<Vec<SessionData>>
List sessions owned by a user, optionally filtering out expired ones.
§Example
let active = auth.sessions()
.list_for_user_filtered("user-1", SessionFilter::ActiveOnly)
.await?;Sourcepub async fn cleanup_expired(&self) -> Result<()>
pub async fn cleanup_expired(&self) -> Result<()>
Remove expired sessions and tokens.
Auto Trait Implementations§
impl<'a> Freeze for SessionOperations<'a>
impl<'a> !RefUnwindSafe for SessionOperations<'a>
impl<'a> Send for SessionOperations<'a>
impl<'a> Sync for SessionOperations<'a>
impl<'a> Unpin for SessionOperations<'a>
impl<'a> UnsafeUnpin for SessionOperations<'a>
impl<'a> !UnwindSafe for SessionOperations<'a>
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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