Skip to main content

SubscriptionEvent

Enum SubscriptionEvent 

Source
#[non_exhaustive]
pub enum SubscriptionEvent { Activated { item_count: usize, field_count: usize, command_fields: Option<CommandFields>, }, Update(Box<ItemUpdate>), EndOfSnapshot { item_index: usize, }, SnapshotCleared { item_index: usize, }, Overflow { item_index: usize, dropped_count: u64, }, Reconfigured { max_frequency: UpdateFrequency, filtering: Filtering, }, Deferred { reason: String, }, Rejected(ServerError), Unsubscribed, Undecodable { detail: String, }, }
Expand description

Everything one subscription can tell you.

Delivered by Updates. #[non_exhaustive], so match with a trailing _ arm and a later version adding a variant will not break your build.

The ordinary shape of a subscription’s life is Activated, then a run of Updates — snapshot first if one was asked for, real-time after — and finally either Unsubscribed or Rejected. After a session is replaced, a second Activated arrives and the run starts over.

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

Activated

The subscription is live on the server and its shape is now known [docs/spec/04-notifications.md §3.1, §3.2].

Arrives again whenever the subscription is re-created on a session that replaced a lost one, in which case every item’s state has been rebuilt from nothing.

Fields

§item_count: usize

How many items the server resolved the item group into.

§field_count: usize

How many fields the server resolved the field schema into. Every update carries exactly this many values.

§command_fields: Option<CommandFields>

Present exactly for SubscriptionMode::Command subscriptions, which the server activates differently because it must also say where the key and command fields are.

§

Update(Box<ItemUpdate>)

New values for one item [docs/spec/04-notifications.md §2].

The update carries the item’s complete state, not only what changed, so every field is readable; ask ItemUpdate::changed_fields what actually moved.

§

EndOfSnapshot

The snapshot of one item is complete; everything after this is a live change [docs/spec/04-notifications.md §3.5].

Sent in DISTINCT and COMMAND modes. A MERGE snapshot is a single update and gets no boundary marker; RAW has no snapshot at all.

Fields

§item_index: usize

1-based index of the item whose snapshot ended.

§

SnapshotCleared

The server cleared one item’s snapshot [docs/spec/04-notifications.md §3.6].

Drop the list, history or row set you accumulated for this item. The field values this crate tracks are deliberately not cleared, so that a delta arriving straight afterwards still decodes.

Fields

§item_index: usize

1-based index of the item whose snapshot was cleared.

§

Overflow

The server dropped updates for one item, because of its own buffer limits [docs/spec/04-notifications.md §3.7].

Those updates are gone; nothing can reconstruct them, and the item’s values now reflect only what survived. This is the protocol’s own way of surfacing loss rather than hiding it, and this crate passes it straight through.

It can only happen in RAW mode, for ADD/DELETE events in COMMAND mode, and for subscriptions that asked for MaxFrequency::Unfiltered.

Fields

§item_index: usize

1-based index of the item whose updates were dropped.

§dropped_count: u64

How many update events were dropped.

§

Reconfigured

The subscription’s frequency configuration [docs/spec/04-notifications.md §3.8].

Arrives once when the subscription starts — possibly before Activated — and again after every reconfiguration, even one that changed nothing.

Fields

§max_frequency: UpdateFrequency

The rate now in force.

§filtering: Filtering

Whether the server may filter.

§

Deferred

The subscription request could not be sent, and will be retried when the session next binds.

Not terminal, and not a refusal. The server never saw the request — the connection was gone, or the transport rejected it — so it has no opinion on your subscription yet. This crate keeps the subscription in its desired set and re-issues it on the next connection, after which Activated arrives as usual.

You do not have to do anything. It is surfaced because it means a real delay before data starts, and a subscription that seems slow to start should not be a mystery.

Fields

§reason: String

What stopped it. Diagnostic text; never a credential.

§

Rejected(ServerError)

The server refused the subscription, with a code from Appendix B [docs/spec/05-error-codes.md §2].

Terminal: nothing else arrives on this stream, and the subscription is not retried on a later session. Common causes are a bad item group (code 21), a bad field schema (23), a mode the item does not allow (24), and — in COMMAND mode — a schema with no key or no command field (15, 16).

Contrast Deferred, where the request never reached the server and is still coming.

§

Unsubscribed

The subscription ended [docs/spec/04-notifications.md §3.4].

Terminal: no further update for these items and fields will be sent.

§

Undecodable

A notification for this subscription could not be interpreted.

Never fatal and never silent: the stream keeps running, and the item state it refers to is whatever the last decodable update left. Seeing this repeatedly means this client and the server disagree about the subscription’s shape, which is worth reporting as a bug.

Fields

§detail: String

What went wrong, in terms a bug report can use.

Implementations§

Source§

impl SubscriptionEvent

Source

pub const fn is_terminal(&self) -> bool

Whether nothing further will arrive on this subscription’s stream.

Trait Implementations§

Source§

impl Clone for SubscriptionEvent

Source§

fn clone(&self) -> SubscriptionEvent

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 SubscriptionEvent

Source§

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

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

impl Eq for SubscriptionEvent

Source§

impl PartialEq for SubscriptionEvent

Source§

fn eq(&self, other: &SubscriptionEvent) -> 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 SubscriptionEvent

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