pub struct SessionRefreshRecord {
pub session_id: SessionId,
pub family_id: SessionFamilyId,
pub expires_at: SystemTime,
pub revoked: bool,
}Expand description
Repository-facing record for the currently active refresh token of a session.
§Examples
use std::time::{Duration, SystemTime};
use webgates_sessions::session::{SessionFamilyId, SessionId, SessionRefreshRecord};
let now = SystemTime::UNIX_EPOCH + Duration::from_secs(1_000);
let expires_at = now + Duration::from_secs(3_600);
let refresh = SessionRefreshRecord::new(SessionId::new(), SessionFamilyId::new(), expires_at);
assert!(refresh.is_active_at(now));
assert!(!refresh.is_expired_at(now));
let revoked = refresh.revoked();
assert!(!revoked.is_active_at(now));Fields§
§session_id: SessionIdSession that owns the refresh token.
family_id: SessionFamilyIdSession family that owns the refresh token.
expires_at: SystemTimeTimestamp when the current refresh token expires.
revoked: boolWhether the refresh token is currently revoked.
Implementations§
Source§impl SessionRefreshRecord
impl SessionRefreshRecord
Sourcepub fn new(
session_id: SessionId,
family_id: SessionFamilyId,
expires_at: SystemTime,
) -> Self
pub fn new( session_id: SessionId, family_id: SessionFamilyId, expires_at: SystemTime, ) -> Self
Creates a new active refresh-token record.
Sourcepub fn is_active_at(&self, now: SystemTime) -> bool
pub fn is_active_at(&self, now: SystemTime) -> bool
Returns true when the refresh token is active at now.
Sourcepub fn is_expired_at(&self, now: SystemTime) -> bool
pub fn is_expired_at(&self, now: SystemTime) -> bool
Returns true when the refresh token has expired at now.
Trait Implementations§
Source§impl Clone for SessionRefreshRecord
impl Clone for SessionRefreshRecord
Source§fn clone(&self) -> SessionRefreshRecord
fn clone(&self) -> SessionRefreshRecord
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SessionRefreshRecord
impl Debug for SessionRefreshRecord
Source§impl PartialEq for SessionRefreshRecord
impl PartialEq for SessionRefreshRecord
Source§fn eq(&self, other: &SessionRefreshRecord) -> bool
fn eq(&self, other: &SessionRefreshRecord) -> bool
Tests for
self and other values to be equal, and is used by ==.impl Eq for SessionRefreshRecord
impl StructuralPartialEq for SessionRefreshRecord
Auto Trait Implementations§
impl Freeze for SessionRefreshRecord
impl RefUnwindSafe for SessionRefreshRecord
impl Send for SessionRefreshRecord
impl Sync for SessionRefreshRecord
impl Unpin for SessionRefreshRecord
impl UnsafeUnpin for SessionRefreshRecord
impl UnwindSafe for SessionRefreshRecord
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