#[non_exhaustive]pub struct Session {Show 25 fields
pub session_id: String,
pub state: SessionState,
pub ttl_expiry: i64,
pub ttl_ms: i64,
pub started_at_unix_ms: i64,
pub resolution: Option<Vec<u8>>,
pub mode: String,
pub mode_state: Vec<u8>,
pub participants: Vec<String>,
pub seen_message_ids: HashSet<String>,
pub intent: String,
pub mode_version: String,
pub configuration_version: String,
pub policy_version: String,
pub context_id: String,
pub extensions: HashMap<String, Vec<u8>>,
pub roots: Vec<Root>,
pub initiator_sender: String,
pub participant_message_counts: HashMap<String, u32>,
pub participant_last_seen: HashMap<String, i64>,
pub policy_definition: Option<PolicyDefinition>,
pub suspended_at_ms: Option<i64>,
pub accumulated_suspended_ms: i64,
pub semantics_rev: u32,
pub max_suspend_ms: i64,
}Expand description
Session model. Fields are public for reads, but the struct is
#[non_exhaustive]: construct via Session::builder. This lets the model
gain fields without breaking every constructor in downstream crates
(pre-1.0 freeze requirement).
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.session_id: String§state: SessionState§ttl_expiry: i64§ttl_ms: i64§started_at_unix_ms: i64§resolution: Option<Vec<u8>>§mode: String§mode_state: Vec<u8>§participants: Vec<String>§seen_message_ids: HashSet<String>§intent: String§mode_version: String§configuration_version: String§policy_version: String§context_id: String§extensions: HashMap<String, Vec<u8>>§roots: Vec<Root>§initiator_sender: String§participant_message_counts: HashMap<String, u32>§participant_last_seen: HashMap<String, i64>§policy_definition: Option<PolicyDefinition>§suspended_at_ms: Option<i64>Wall-clock (session-timeline) ms at which the session was suspended, or
None when not suspended. Used to bank TTL across a suspension (§7.5).
accumulated_suspended_ms: i64Cumulative ms the session has spent suspended across all suspend/resume
cycles. Drives the MAX_SUSPEND_MS cap.
semantics_rev: u32Session-semantics revision this session was accepted under. See
CURRENT_SEMANTICS_REV. Legacy persisted sessions load as 0.
max_suspend_ms: i64Maximum-suspension cap bound at SessionStart (RFC-MACP-0001 §7.5,
RFC-MACP-0003 §2). 0 = unbound (legacy sessions and library
defaults) — the MAX_SUSPEND_MS default applies; see
Session::effective_max_suspend_ms. The kernel records the
resolved value here for new sessions.
Implementations§
Source§impl Session
impl Session
Sourcepub fn builder(
session_id: impl Into<String>,
mode: impl Into<String>,
initiator_sender: impl Into<String>,
) -> SessionBuilder
pub fn builder( session_id: impl Into<String>, mode: impl Into<String>, initiator_sender: impl Into<String>, ) -> SessionBuilder
Start building a Session. The three arguments are the fields with no
meaningful default; everything else starts from documented defaults
(see SessionBuilder) and is set with the builder’s methods.
pub fn record_participant_activity(&mut self, sender: &str, timestamp_ms: i64)
Sourcepub fn suspend(&mut self, now_ms: i64) -> Result<(), MacpError>
pub fn suspend(&mut self, now_ms: i64) -> Result<(), MacpError>
Suspend an Open session (RFC-MACP-0001 §7.5). Records the suspend time
so TTL can be banked on resume. Pure: no clock, no I/O — the caller
injects now_ms.
Sourcepub fn effective_max_suspend_ms(&self) -> i64
pub fn effective_max_suspend_ms(&self) -> i64
Resume a Suspended session, banking the suspended duration into the
TTL deadline (ttl_expiry += now - suspended_at). If the cumulative
suspended time would exceed MAX_SUSPEND_MS, the session is force-expired
instead and MacpError::TtlExpired is returned.
The suspension cap governing this session: the value bound at
SessionStart, or the MAX_SUSPEND_MS default when unbound (0).
pub fn resume(&mut self, now_ms: i64) -> Result<(), MacpError>
Sourcepub fn cancel(&mut self) -> Result<(), MacpError>
pub fn cancel(&mut self) -> Result<(), MacpError>
Cancel an Open or Suspended session into the terminal Cancelled
state (RFC-MACP-0001 §7.3). Returns an error if already terminal.
Sourcepub fn suspend_cap_exceeded(&self, now_ms: i64) -> bool
pub fn suspend_cap_exceeded(&self, now_ms: i64) -> bool
Whether a currently-Suspended session has exceeded MAX_SUSPEND_MS as
of now_ms (cumulative banked plus the in-progress suspension).