Skip to main content

SessionStore

Struct SessionStore 

Source
pub struct SessionStore { /* private fields */ }
Expand description

Store of all sessions managed by the ProtocolMachine.

Provides type lookup/update methods that match the Lean SessionStore.lookupType / SessionStore.updateType pattern.

Implementations§

Source§

impl SessionStore

Source

pub fn new() -> Self

Create an empty session store.

Source

pub fn open_with_sid( &mut self, sid: SessionId, roles: Vec<String>, buffer_config: &BufferConfig, initial_types: &BTreeMap<String, LocalTypeR>, ) -> SessionId

Open a new session with an externally supplied session id.

Callers should source ids from SessionStore::next_session_id().

Source

pub fn open_with_sid_from_plan( &mut self, sid: SessionId, plan: &SessionOpenPlan, buffer_config: &BufferConfig, ) -> SessionId

Open a new session from a reusable precomputed open plan.

Source

pub fn open( &mut self, roles: Vec<String>, buffer_config: &BufferConfig, initial_types: &BTreeMap<String, LocalTypeR>, ) -> SessionId

Open a new session with the given roles, buffer config, and initial local types.

Returns the session ID. Endpoints are constructed as Endpoint { sid, role }.

Source

pub fn next_session_id(&self) -> SessionId

Next session identifier that will be allocated by open.

Source

pub fn lookup_type(&self, ep: &Endpoint) -> Option<&LocalTypeR>

Lookup the current local type for an endpoint.

Matches Lean SessionStore.lookupType.

Source

pub fn update_type(&mut self, ep: &Endpoint, new_type: LocalTypeR)

Update the local type for an endpoint (type advancement on commit).

Matches Lean SessionStore.updateType.

Source

pub fn update_original(&mut self, ep: &Endpoint, new_original: LocalTypeR)

Update the original type (when entering a new Mu scope).

Source

pub fn original_type(&self, ep: &Endpoint) -> Option<&LocalTypeR>

Get the original type for recursive unfolding.

Source

pub fn remove_type(&mut self, ep: &Endpoint)

Remove type entry (on Halt/End — session endpoint completed).

Source

pub fn get(&self, sid: SessionId) -> Option<&SessionState>

Get a reference to a session.

Source

pub fn get_mut(&mut self, sid: SessionId) -> Option<&mut SessionState>

Get a mutable reference to a session.

Source

pub fn current_ownership(&self, sid: SessionId) -> Option<&OwnershipCapability>

Get the current live ownership capability for a session, if any.

Source

pub fn validate_ownership_capability( &self, capability: &OwnershipCapability, ) -> Result<(), OwnershipError>

Validate that a capability still matches the live owner state.

§Errors

Returns an OwnershipError if the session is missing, terminal, or stale.

Source

pub fn authority_audit_log( &self, sid: SessionId, ) -> Option<&[AuthorityAuditRecord]>

Read deterministic authority audit records for one session.

Source

pub fn claim_ownership( &mut self, sid: SessionId, owner_id: impl Into<FragmentOwnerId>, scope: OwnershipScope, ) -> Result<OwnershipCapability, OwnershipError>

Claim ownership for an unclaimed session.

§Errors

Returns an OwnershipError if the session is missing, terminal, or already claimed.

Source

pub fn release_ownership( &mut self, capability: &OwnershipCapability, ) -> Result<(), OwnershipError>

Release the current owner capability for a session.

§Errors

Returns an OwnershipError if the capability is stale or a transfer is still pending.

Source

pub fn begin_ownership_transfer( &mut self, capability: &OwnershipCapability, new_owner_id: impl Into<FragmentOwnerId>, new_scope: OwnershipScope, ) -> Result<OwnershipReceipt, OwnershipError>

Begin an explicit ownership transfer and return a typed receipt.

§Errors

Returns an OwnershipError if the capability is stale or another transfer is pending.

Source

pub fn commit_ownership_transfer( &mut self, receipt: &OwnershipReceipt, ) -> Result<OwnershipCapability, OwnershipError>

Commit a previously staged ownership transfer.

§Errors

Returns an OwnershipError if the receipt is stale or mismatched.

Source

pub fn rollback_ownership_transfer( &mut self, receipt: &OwnershipReceipt, ) -> Result<(), OwnershipError>

Roll back only the staged transfer identified by this receipt.

§Errors

Returns an OwnershipError if the receipt does not match the current staged transfer.

Source

pub fn attenuate_ownership_scope( &mut self, capability: &OwnershipCapability, new_scope: OwnershipScope, ) -> Result<OwnershipCapability, OwnershipError>

Attenuate or otherwise change scope for the same owner.

§Errors

Returns an OwnershipError if the capability is stale or a transfer is pending.

Source

pub fn apply_owned_session_mutation( &mut self, capability: &OwnershipCapability, mutation: SessionHostMutation, ) -> Result<(), OwnershipError>

Apply session-local host mutation through the ownership gate.

§Errors

Returns an OwnershipError if the capability is stale or lacks full-session scope.

Source

pub fn issue_readiness_witness( &mut self, capability: &OwnershipCapability, predicate_ref: impl Into<String>, ) -> Result<ReadinessWitness, OwnershipError>

Issue a single-use readiness witness under the current owner capability.

§Errors

Returns an OwnershipError if the capability is stale or lacks full-session scope.

Source

pub fn consume_readiness_witness( &mut self, capability: &OwnershipCapability, witness: &ReadinessWitness, ) -> Result<(), OwnershipError>

Consume a readiness witness exactly once under the same live owner capability.

§Errors

Returns an OwnershipError if the witness is stale, forged, mismatched, or already used.

Source

pub fn mark_owner_died( &mut self, sid: SessionId, owner_id: &str, ) -> Result<CancellationWitness, OwnershipError>

Mark the current owner as dead and fault the session.

§Errors

Returns an OwnershipError if the session is missing or owner mismatch occurs.

Source

pub fn cancel_abandoned_transfer( &mut self, receipt: &OwnershipReceipt, ) -> Result<CancellationWitness, OwnershipError>

Cancel a session because a staged transfer was abandoned.

§Errors

Returns an OwnershipError if the receipt does not match the staged transfer.

Source

pub fn fault_failed_transfer_commit( &mut self, receipt: &OwnershipReceipt, reason: impl Into<String>, ) -> Result<(), OwnershipError>

Fault a session because a staged transfer could not commit.

§Errors

Returns an OwnershipError if the receipt does not match the staged transfer.

Source

pub fn iter(&self) -> impl Iterator<Item = &SessionState>

Iterate over all sessions.

Source

pub fn close(&mut self, sid: SessionId) -> Result<(), String>

Close a session.

§Errors

Returns an error if the session is not found.

Source

pub fn closed_session_ids(&self) -> Vec<SessionId>

Closed/cancelled/faulted session identifiers still resident in the store.

Source

pub fn reap_sessions( &mut self, session_ids: &[SessionId], ) -> Vec<ClosedSessionSummary>

Reap specific session ids from live storage and archive compact summaries.

§Panics

Panics if a session disappears between the initial residency/status check and the subsequent removal from the store.

Source

pub fn reap_closed(&mut self) -> Vec<ClosedSessionSummary>

Reap all closed/cancelled/faulted sessions from live storage.

Source

pub fn active_count(&self) -> usize

Number of active sessions.

Source

pub fn live_count(&self) -> usize

Number of sessions still resident in the store.

Source

pub fn session_ids(&self) -> Vec<SessionId>

All session IDs.

Source

pub fn archived_closed(&self) -> &[ClosedSessionSummary]

Archived closed-session summaries retained after reaping.

Source

pub fn memory_usage(&self) -> SessionStoreMemoryUsage

Approximate retained state for the session store.

Source

pub fn lookup_handler(&self, edge: &Edge) -> Option<&HandlerId>

Lookup edge-bound handler id.

Source

pub fn default_handler_for_session(&self, sid: SessionId) -> Option<&HandlerId>

Lookup a default handler id for a session.

Source

pub fn lookup_trace(&self, edge: &Edge) -> Option<&[ValType]>

Lookup coherence trace for an edge.

Trait Implementations§

Source§

impl Debug for SessionStore

Source§

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

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

impl Default for SessionStore

Source§

fn default() -> SessionStore

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for SessionStore

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for SessionStore

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
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<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
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<Src, Dst> LosslessTryInto<Dst> for Src
where Dst: LosslessTryFrom<Src>,

Source§

fn lossless_try_into(self) -> Option<Dst>

Performs the conversion.
Source§

impl<Src, Dst> LossyInto<Dst> for Src
where Dst: LossyFrom<Src>,

Source§

fn lossy_into(self) -> Dst

Performs the conversion.
Source§

impl<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> StrictAs for T

Source§

fn strict_as<Dst>(self) -> Dst
where T: StrictCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> StrictCastFrom<Src> for Dst
where Src: StrictCast<Dst>,

Source§

fn strict_cast_from(src: Src) -> Dst

Casts the value.
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.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,