Skip to main content

WsUpdate

Enum WsUpdate 

Source
pub enum WsUpdate {
    Snapshot {
        market_id: String,
        asset_id: String,
        book: Arc<Orderbook>,
        exchange_ts: Option<u64>,
        local_ts: Instant,
        local_ts_ms: u64,
        seq: u64,
    },
    Delta {
        market_id: String,
        asset_id: String,
        changes: ChangeVec,
        exchange_ts: Option<u64>,
        local_ts: Instant,
        local_ts_ms: u64,
        seq: u64,
    },
    Clear {
        market_id: String,
        asset_id: String,
        reason: InvalidationReason,
        local_ts: Instant,
        local_ts_ms: u64,
        seq: u64,
    },
    Trade {
        trade: ActivityTrade,
        local_ts: Instant,
        local_ts_ms: u64,
    },
    Fill {
        fill: ActivityFill,
        local_ts: Instant,
        local_ts_ms: u64,
    },
}
Expand description

Every per-market event the WebSocket surface emits. Closed tagged union; no untyped escape hatch in the stable enum. If an exchange grows a payload we want to surface in raw form, add a separate raw_events() stream rather than another WsUpdate variant — keeps consumer match exhaustiveness honest.

Variants§

§

Snapshot

Full orderbook snapshot. Caller should replace any cached book keyed by (market_id, asset_id). market_id is the parent market on every exchange; asset_id is the per-outcome identifier (Polymarket token, Kalshi ticker, Opinion numeric market id). Emitted on initial subscribe and after any BookInvalidated / Clear recovery path.

Fields

§market_id: String
§asset_id: String
§exchange_ts: Option<u64>
§local_ts: Instant
§local_ts_ms: u64
§seq: u64
§

Delta

Incremental change to an existing book. Apply in-place, or discard if the caller has seen a matching Clear / BookInvalidated without a follow-up Snapshot yet.

Fields

§market_id: String
§asset_id: String
§changes: ChangeVec
§exchange_ts: Option<u64>
§local_ts: Instant
§local_ts_ms: u64
§seq: u64
§

Clear

Book invalidation on the same stream as Snapshot / Delta, so a consumer can say “seq N was Clear, drop anything with seq ≤ N, wait for the next Snapshot” without merging with the session stream. Mirrors SessionEvent::BookInvalidated, which stays as the connection-level signal for global observability.

Fields

§market_id: String
§asset_id: String
§local_ts: Instant
§local_ts_ms: u64
§seq: u64
§

Trade

A public trade (any counterparty). Not tied to a local order.

Fields

§local_ts: Instant
§local_ts_ms: u64
§

Fill

A fill on one of the authenticated user’s orders.

Fields

§local_ts: Instant
§local_ts_ms: u64

Implementations§

Source§

impl WsUpdate

Source

pub fn local_ts(&self) -> Instant

Uniform accessor for the ingest-side monotonic timestamp. Use for metrics and cross-update ordering; for per-market sequencing prefer the seq field on Snapshot / Delta.

Source

pub fn local_ts_ms(&self) -> u64

Wall-clock millis paired with local_ts. Use for serialization and any cross-process correlation; not monotonic.

Source

pub fn market_id(&self) -> Option<&str>

Market ID for events scoped to a single market.

Source

pub fn asset_id(&self) -> Option<&str>

Asset ID for book-scoped events. Returns None for activity events (Trade / Fill) where the asset is carried on the inner payload.

Trait Implementations§

Source§

impl Clone for WsUpdate

Source§

fn clone(&self) -> WsUpdate

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for WsUpdate

Source§

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

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

impl Serialize for WsUpdate

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