Skip to main content

Session

Struct Session 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional 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: i64

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

§semantics_rev: u32

Session-semantics revision this session was accepted under. See CURRENT_SEMANTICS_REV. Legacy persisted sessions load as 0.

§max_suspend_ms: i64

Maximum-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

Source

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.

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

Source

pub fn resume(&mut self, now_ms: i64) -> Result<(), MacpError>

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<(), Error>

Formats the value using the given formatter. Read more
Source§

impl From<&Session> for PersistedSession

Source§

fn from(session: &Session) -> PersistedSession

Converts to this type from the input type.
Source§

impl From<PersistedSession> for Session

Source§

fn from(session: PersistedSession) -> Session

Converts to this type from the input type.

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> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more