Skip to main content

SessionManager

Struct SessionManager 

Source
pub struct SessionManager<T> { /* private fields */ }
Expand description

Generic session manager for protocol-agnostic session coordination

Time System: Uses PhysicalTime for timestamps per the unified time architecture.

Implementations§

Source§

impl<T> SessionManager<T>
where T: Clone + Send + Sync + Serialize + for<'de> Deserialize<'de>,

Source

pub fn new(config: SessionConfig, now: PhysicalTime) -> Self

Create a new session manager

Time System: Uses PhysicalTime for timestamps.

Source

pub fn new_from_ms(config: SessionConfig, now_ms: u64) -> Self

Create a new session manager from milliseconds timestamp

Convenience constructor for backward compatibility.

Source

pub fn with_metrics( config: SessionConfig, metrics: MetricsCollector, now: PhysicalTime, ) -> Self

Create session manager with metrics collection

Time System: Uses PhysicalTime for timestamps.

Source

pub fn create_session( &mut self, participants: Vec<DeviceId>, now: &PhysicalTime, ) -> SyncResult<SessionId>

Create a new session with participants

Time System: Uses PhysicalTime for timestamps. Note: Callers should obtain now via their time provider and pass it to this method

Source

pub fn create_session_ms( &mut self, participants: Vec<DeviceId>, now_ms: u64, ) -> SyncResult<SessionId>

Create a new session with participants (from milliseconds)

Convenience method for backward compatibility.

Source

pub fn activate_session( &mut self, session_id: SessionId, protocol_state: T, current_time: &PhysicalTime, ) -> SyncResult<()>

Activate a session with initial protocol state

Time System: Uses PhysicalTime for timestamps.

Source

pub fn activate_session_ms( &mut self, session_id: SessionId, protocol_state: T, current_timestamp_ms: u64, ) -> SyncResult<()>

Activate a session with initial protocol state (from milliseconds)

Convenience method for backward compatibility.

Source

pub fn update_session( &mut self, session_id: SessionId, new_state: T, current_time: &PhysicalTime, ) -> SyncResult<()>
where T: Debug,

Update session protocol state

Time System: Uses PhysicalTime for timestamps.

Source

pub fn update_session_ms( &mut self, session_id: SessionId, new_state: T, current_timestamp_ms: u64, ) -> SyncResult<()>
where T: Debug,

Update session protocol state (from milliseconds)

Convenience method for backward compatibility.

Source

pub fn complete_session( &mut self, session_id: SessionId, operations_count: u64, bytes_transferred: u64, metadata: HashMap<String, String>, current_time: &PhysicalTime, ) -> SyncResult<()>

Complete a session successfully

Time System: Uses PhysicalTime for timestamps.

Source

pub fn complete_session_ms( &mut self, session_id: SessionId, operations_count: u64, bytes_transferred: u64, metadata: HashMap<String, String>, current_timestamp_ms: u64, ) -> SyncResult<()>

Complete a session successfully (from milliseconds)

Convenience method for backward compatibility.

Source

pub fn fail_session( &mut self, session_id: SessionId, error: SessionError, partial_results: Option<PartialResults>, current_time: &PhysicalTime, ) -> SyncResult<()>

Fail a session with error context

Time System: Uses PhysicalTime for timestamps.

Source

pub fn fail_session_ms( &mut self, session_id: SessionId, error: SessionError, partial_results: Option<PartialResults>, current_timestamp_ms: u64, ) -> SyncResult<()>

Fail a session with error context (from milliseconds)

Convenience method for backward compatibility.

Source

pub fn timeout_session( &mut self, session_id: SessionId, current_time: &PhysicalTime, ) -> SyncResult<()>
where T: Debug,

Timeout a session

Time System: Uses PhysicalTime for timestamps.

Source

pub fn timeout_session_ms( &mut self, session_id: SessionId, current_timestamp_ms: u64, ) -> SyncResult<()>
where T: Debug,

Timeout a session (from milliseconds)

Convenience method for backward compatibility.

Source

pub fn get_session(&self, session_id: &SessionId) -> Option<&SessionState<T>>

Get session state

Source

pub fn get_protocol_state(&self, session_id: &SessionId) -> Option<&T>

Get protocol state for active session

Source

pub fn active_sessions(&self) -> Vec<(SessionId, &SessionState<T>)>

List all active sessions

Source

pub fn count_active_sessions(&self) -> usize

Count active sessions

Source

pub fn count_completed_sessions(&self) -> usize

Count completed sessions

Source

pub fn cleanup_stale_sessions( &mut self, now: &PhysicalTime, ) -> SyncResult<usize>
where T: Debug,

Cleanup stale and completed sessions

Time System: Uses PhysicalTime for timestamps. Note: Callers should obtain now via their time provider and pass it to this method

Source

pub fn cleanup_stale_sessions_ms(&mut self, now_ms: u64) -> SyncResult<usize>
where T: Debug,

Cleanup stale and completed sessions (from milliseconds)

Convenience method for backward compatibility.

Source

pub fn get_statistics(&self) -> SessionManagerStatistics

Get session statistics

Source

pub fn close_session(&mut self, peer: DeviceId) -> SyncResult<()>

Close a session for a specific peer

Source

pub fn has_active_session(&self, peer: DeviceId) -> bool

Check if peer has an active session

Auto Trait Implementations§

§

impl<T> Freeze for SessionManager<T>

§

impl<T> RefUnwindSafe for SessionManager<T>
where T: RefUnwindSafe,

§

impl<T> Send for SessionManager<T>
where T: Send,

§

impl<T> Sync for SessionManager<T>
where T: Sync,

§

impl<T> Unpin for SessionManager<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for SessionManager<T>

§

impl<T> UnwindSafe for SessionManager<T>
where T: UnwindSafe,

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> 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> IntoViewDelta for T
where T: Any + Send + Sync,

Source§

fn into_view_delta(self) -> Box<dyn Any + Send + Sync>

Convert self into a type-erased ViewDelta.
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<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
Source§

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

Source§

fn vzip(self) -> V

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
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> Endpoint for T
where T: Send,