Skip to main content

Session

Struct Session 

Source
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: i64

Cumulative ms the session has spent suspended across all suspend/resume cycles. Drives the MAX_SUSPEND_MS cap.

Implementations§

Source§

impl Session

Source

pub fn record_participant_activity(&mut self, sender: &str, timestamp_ms: i64)

Source

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.

Source

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.

Source

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.

Source

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).

Source

pub fn apply_mode_response(&mut self, response: ModeResponse)

Trait Implementations§

Source§

impl Clone for Session

Source§

fn clone(&self) -> Session

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Session

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.