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
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
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
reason: InvalidationReasonTrade
A public trade (any counterparty). Not tied to a local order.
Fill
A fill on one of the authenticated user’s orders.
Implementations§
Source§impl WsUpdate
impl WsUpdate
Sourcepub fn local_ts(&self) -> Instant
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.
Sourcepub fn local_ts_ms(&self) -> u64
pub fn local_ts_ms(&self) -> u64
Wall-clock millis paired with local_ts. Use for serialization and
any cross-process correlation; not monotonic.