pub struct Session {
pub session_id: String,
pub user_id: String,
pub auth_context: AuthContext,
pub created_at: DateTime<Utc>,
pub last_accessed: DateTime<Utc>,
pub expires_at: DateTime<Utc>,
pub client_ip: Option<String>,
pub user_agent: Option<String>,
pub metadata: HashMap<String, String>,
pub is_active: bool,
pub refresh_token: Option<String>,
}
Expand description
Session information
Fields§
§session_id: String
Unique session identifier
user_id: String
User/API key identifier
auth_context: AuthContext
Authentication context
created_at: DateTime<Utc>
Session creation timestamp
last_accessed: DateTime<Utc>
Session last accessed timestamp
expires_at: DateTime<Utc>
Session expiration timestamp
client_ip: Option<String>
Client IP address
user_agent: Option<String>
User agent string
metadata: HashMap<String, String>
Session metadata
is_active: bool
Whether session is active
refresh_token: Option<String>
JWT refresh token (if applicable)
Implementations§
Source§impl Session
impl Session
Sourcepub fn new(
user_id: String,
auth_context: AuthContext,
duration: Duration,
) -> Self
pub fn new( user_id: String, auth_context: AuthContext, duration: Duration, ) -> Self
Create a new session
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Check if session is expired
Sourcepub fn with_metadata(self, key: String, value: String) -> Self
pub fn with_metadata(self, key: String, value: String) -> Self
Add metadata to session
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Session
impl<'de> Deserialize<'de> for Session
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Session
impl RefUnwindSafe for Session
impl Send for Session
impl Sync for Session
impl Unpin for Session
impl UnwindSafe for Session
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