pub struct Session {Show 23 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,
}Fields§
§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.
Implementations§
Source§impl Session
impl Session
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 resume(&mut self, now_ms: i64) -> Result<(), MacpError>
pub fn resume(&mut self, now_ms: i64) -> Result<(), MacpError>
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.
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).
pub fn apply_mode_response(&mut self, response: ModeResponse)
Trait Implementations§
Source§impl From<&Session> for PersistedSession
impl From<&Session> for PersistedSession
Source§fn from(session: &Session) -> PersistedSession
fn from(session: &Session) -> PersistedSession
Source§impl From<PersistedSession> for Session
impl From<PersistedSession> for Session
Source§fn from(session: PersistedSession) -> Session
fn from(session: PersistedSession) -> Session
Auto Trait Implementations§
impl Freeze for Session
impl RefUnwindSafe for Session
impl Send for Session
impl Sync for Session
impl Unpin for Session
impl UnsafeUnpin 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request