pub struct SessionState {
pub session_id: String,
pub state: HashMap<String, Value>,
pub history: Vec<InteractionRecord>,
pub created_at: DateTime<Utc>,
pub last_activity: DateTime<Utc>,
pub metadata: HashMap<String, String>,
}Expand description
Session state snapshot
Fields§
§session_id: StringSession ID
state: HashMap<String, Value>Current state data (e.g., logged-in user, cart items, etc.)
history: Vec<InteractionRecord>Interaction history for this session
created_at: DateTime<Utc>Session creation time
last_activity: DateTime<Utc>Last activity time
metadata: HashMap<String, String>Session metadata
Implementations§
Source§impl SessionState
impl SessionState
Sourcepub fn new(session_id: impl Into<String>) -> Self
pub fn new(session_id: impl Into<String>) -> Self
Create a new session state.
Uses crate::clock::now() which respects any registered virtual clock
(see mockforge_foundation::clock::set_clock).
Sourcepub fn touch(&mut self)
pub fn touch(&mut self)
Update last activity timestamp.
Uses crate::clock::now() which respects any registered virtual clock.
Sourcepub fn record_interaction(&mut self, interaction: InteractionRecord)
pub fn record_interaction(&mut self, interaction: InteractionRecord)
Add an interaction to history.
Sourcepub fn is_inactive(&self, duration: Duration) -> bool
pub fn is_inactive(&self, duration: Duration) -> bool
Check if session has been inactive for a duration.
Uses crate::clock::now() which respects any registered virtual clock.
Trait Implementations§
Source§impl Clone for SessionState
impl Clone for SessionState
Source§fn clone(&self) -> SessionState
fn clone(&self) -> SessionState
Returns a duplicate of the value. Read more
1.0.0 · 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 SessionState
impl Debug for SessionState
Source§impl<'de> Deserialize<'de> for SessionState
impl<'de> Deserialize<'de> for SessionState
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 SessionState
impl RefUnwindSafe for SessionState
impl Send for SessionState
impl Sync for SessionState
impl Unpin for SessionState
impl UnsafeUnpin for SessionState
impl UnwindSafe for SessionState
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