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
impl SessionStore
Sourcepub fn open_with_sid(
&mut self,
sid: SessionId,
roles: Vec<String>,
buffer_config: &BufferConfig,
initial_types: &BTreeMap<String, LocalTypeR>,
) -> SessionId
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().
Sourcepub fn open_with_sid_from_plan(
&mut self,
sid: SessionId,
plan: &SessionOpenPlan,
buffer_config: &BufferConfig,
) -> SessionId
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.
Sourcepub fn open(
&mut self,
roles: Vec<String>,
buffer_config: &BufferConfig,
initial_types: &BTreeMap<String, LocalTypeR>,
) -> SessionId
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 }.
Sourcepub fn next_session_id(&self) -> SessionId
pub fn next_session_id(&self) -> SessionId
Next session identifier that will be allocated by open.
Sourcepub fn lookup_type(&self, ep: &Endpoint) -> Option<&LocalTypeR>
pub fn lookup_type(&self, ep: &Endpoint) -> Option<&LocalTypeR>
Lookup the current local type for an endpoint.
Matches Lean SessionStore.lookupType.
Sourcepub fn update_type(&mut self, ep: &Endpoint, new_type: LocalTypeR)
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.
Sourcepub fn update_original(&mut self, ep: &Endpoint, new_original: LocalTypeR)
pub fn update_original(&mut self, ep: &Endpoint, new_original: LocalTypeR)
Update the original type (when entering a new Mu scope).
Sourcepub fn original_type(&self, ep: &Endpoint) -> Option<&LocalTypeR>
pub fn original_type(&self, ep: &Endpoint) -> Option<&LocalTypeR>
Get the original type for recursive unfolding.
Sourcepub fn remove_type(&mut self, ep: &Endpoint)
pub fn remove_type(&mut self, ep: &Endpoint)
Remove type entry (on Halt/End — session endpoint completed).
Sourcepub fn get(&self, sid: SessionId) -> Option<&SessionState>
pub fn get(&self, sid: SessionId) -> Option<&SessionState>
Get a reference to a session.
Sourcepub fn get_mut(&mut self, sid: SessionId) -> Option<&mut SessionState>
pub fn get_mut(&mut self, sid: SessionId) -> Option<&mut SessionState>
Get a mutable reference to a session.
Sourcepub fn current_ownership(&self, sid: SessionId) -> Option<&OwnershipCapability>
pub fn current_ownership(&self, sid: SessionId) -> Option<&OwnershipCapability>
Get the current live ownership capability for a session, if any.
Sourcepub fn validate_ownership_capability(
&self,
capability: &OwnershipCapability,
) -> Result<(), OwnershipError>
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.
Read deterministic authority audit records for one session.
Sourcepub fn claim_ownership(
&mut self,
sid: SessionId,
owner_id: impl Into<FragmentOwnerId>,
scope: OwnershipScope,
) -> Result<OwnershipCapability, OwnershipError>
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.
Sourcepub fn release_ownership(
&mut self,
capability: &OwnershipCapability,
) -> Result<(), OwnershipError>
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.
Sourcepub fn begin_ownership_transfer(
&mut self,
capability: &OwnershipCapability,
new_owner_id: impl Into<FragmentOwnerId>,
new_scope: OwnershipScope,
) -> Result<OwnershipReceipt, OwnershipError>
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.
Sourcepub fn commit_ownership_transfer(
&mut self,
receipt: &OwnershipReceipt,
) -> Result<OwnershipCapability, OwnershipError>
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.
Sourcepub fn rollback_ownership_transfer(
&mut self,
receipt: &OwnershipReceipt,
) -> Result<(), OwnershipError>
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.
Sourcepub fn attenuate_ownership_scope(
&mut self,
capability: &OwnershipCapability,
new_scope: OwnershipScope,
) -> Result<OwnershipCapability, OwnershipError>
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.
Sourcepub fn apply_owned_session_mutation(
&mut self,
capability: &OwnershipCapability,
mutation: SessionHostMutation,
) -> Result<(), OwnershipError>
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.
Sourcepub fn issue_readiness_witness(
&mut self,
capability: &OwnershipCapability,
predicate_ref: impl Into<String>,
) -> Result<ReadinessWitness, OwnershipError>
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.
Sourcepub fn consume_readiness_witness(
&mut self,
capability: &OwnershipCapability,
witness: &ReadinessWitness,
) -> Result<(), OwnershipError>
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.
Sourcepub fn mark_owner_died(
&mut self,
sid: SessionId,
owner_id: &str,
) -> Result<CancellationWitness, OwnershipError>
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.
Sourcepub fn cancel_abandoned_transfer(
&mut self,
receipt: &OwnershipReceipt,
) -> Result<CancellationWitness, OwnershipError>
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.
Sourcepub fn fault_failed_transfer_commit(
&mut self,
receipt: &OwnershipReceipt,
reason: impl Into<String>,
) -> Result<(), OwnershipError>
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.
Sourcepub fn iter(&self) -> impl Iterator<Item = &SessionState>
pub fn iter(&self) -> impl Iterator<Item = &SessionState>
Iterate over all sessions.
Sourcepub fn closed_session_ids(&self) -> Vec<SessionId> ⓘ
pub fn closed_session_ids(&self) -> Vec<SessionId> ⓘ
Closed/cancelled/faulted session identifiers still resident in the store.
Sourcepub fn reap_sessions(
&mut self,
session_ids: &[SessionId],
) -> Vec<ClosedSessionSummary>
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.
Sourcepub fn reap_closed(&mut self) -> Vec<ClosedSessionSummary>
pub fn reap_closed(&mut self) -> Vec<ClosedSessionSummary>
Reap all closed/cancelled/faulted sessions from live storage.
Sourcepub fn active_count(&self) -> usize
pub fn active_count(&self) -> usize
Number of active sessions.
Sourcepub fn live_count(&self) -> usize
pub fn live_count(&self) -> usize
Number of sessions still resident in the store.
Sourcepub fn session_ids(&self) -> Vec<SessionId> ⓘ
pub fn session_ids(&self) -> Vec<SessionId> ⓘ
All session IDs.
Sourcepub fn archived_closed(&self) -> &[ClosedSessionSummary]
pub fn archived_closed(&self) -> &[ClosedSessionSummary]
Archived closed-session summaries retained after reaping.
Sourcepub fn memory_usage(&self) -> SessionStoreMemoryUsage
pub fn memory_usage(&self) -> SessionStoreMemoryUsage
Approximate retained state for the session store.
Sourcepub fn lookup_handler(&self, edge: &Edge) -> Option<&HandlerId>
pub fn lookup_handler(&self, edge: &Edge) -> Option<&HandlerId>
Lookup edge-bound handler id.
Sourcepub fn default_handler_for_session(&self, sid: SessionId) -> Option<&HandlerId>
pub fn default_handler_for_session(&self, sid: SessionId) -> Option<&HandlerId>
Lookup a default handler id for a session.
Sourcepub fn lookup_trace(&self, edge: &Edge) -> Option<&[ValType]>
pub fn lookup_trace(&self, edge: &Edge) -> Option<&[ValType]>
Lookup coherence trace for an edge.