Skip to main content

Continuity

Enum Continuity 

Source
#[non_exhaustive]
pub enum Continuity { New, Preserved, Recovered { requested_from: u64, }, Replaced { previous_session_id: Option<String>, }, }
Expand description

What a newly bound session means for state you built on the previous one.

This is the distinction ADR-0005 exists for. Read it as: may I keep what I computed? — and Continuity::state_validity is that question asked directly.

Debug redacts the previous session identifier for the reason given on Connected; the field itself is public and unredacted.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

New

The first session of this client.

There is nothing this client preserved, which is not the same as nothing being wrong: an application whose state outlived an earlier client — rebuilt after Error::ReconnectExhausted, say — is holding state derived from a session that no longer exists. That is why Continuity::state_validity answers Invalid here as it does for Replaced.

§

Preserved

The same session, rebound over a fresh connection after a clean handover — the server told the client to reconnect and guaranteed that nothing was dropped in between [docs/spec/02-session-lifecycle.md §4.4].

Every subscription is intact, server-side, with all its items and fields. Keep your state.

§

Recovered

The same session, resumed after an interruption the client recovered from.

Whether anything was actually missed is not known yet at this point: the server answers separately, and this client reports the answer as SessionEvent::Recovered immediately afterwards. Hold your state and decide when Recovery::is_lossless says; this is the case Continuity::state_validity reports as Pending, rather than claiming a preservation the server has not confirmed.

Fields

§requested_from: u64

The point in the session’s notification count the client asked to resume from.

§

Replaced

A new session replaced one that was lost.

Nothing carries over: the notification count restarts at zero and every subscription is created again from scratch [docs/spec/02-session-lifecycle.md §6.1]. Any state you derived from the previous session is stale — discard it and rebuild from the snapshots that follow.

Fields

§previous_session_id: Option<String>

The identifier of the session this one replaces, when there was one and the client knew it.

Implementations§

Source§

impl Continuity

Source

pub const fn state_validity(&self) -> StateValidity

Whether state derived from an earlier session may still be used.

This replaces a boolean that could not tell the truth. Two of the four cases do not answer yes or no:

ContinuityValidityWhy
PreservedValidthe same session, nothing dropped
RecoveredPendingthe same session, but whether a gap opened is not known until the next event
ReplacedInvalida different session; the notification count restarts
NewInvalidthere is no earlier session of this client to have preserved anything

New answering Invalid is the case worth explaining. It is not that something was lost — nothing was — but that nothing was kept, and an application whose state outlives its client (rebuilt after Error::ReconnectExhausted, say) is asking the same question and deserves the same answer. Reporting a first session as “preserved” would tell it to keep a book built on a session that no longer exists.

§Examples
use lightstreamer_rs::{Continuity, StateValidity};

let recovering = Continuity::Recovered { requested_from: 42 };
assert_eq!(recovering.state_validity(), StateValidity::Pending);
assert_eq!(Continuity::New.state_validity(), StateValidity::Invalid);

Trait Implementations§

Source§

impl Clone for Continuity

Source§

fn clone(&self) -> Continuity

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 Continuity

Source§

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

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

impl Eq for Continuity

Source§

impl PartialEq for Continuity

Source§

fn eq(&self, other: &Continuity) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Continuity

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