pub struct BookSyncTracker { /* private fields */ }Expand description
Applies order-book protocol events for the markets a data client has subscribed to.
Implementations§
Source§impl BookSyncTracker
impl BookSyncTracker
Sourcepub fn new(instruments: &[InstrumentId], snapshot_timeout: Duration) -> Self
pub fn new(instruments: &[InstrumentId], snapshot_timeout: Duration) -> Self
Creates a tracker for the selected markets.
snapshot_timeout bounds how long an initial book may wait before recovery. Zero starts that
wait immediately.
Sourcepub fn subscribe(
&self,
id: InstrumentId,
ws_client: Option<&KalshiWebSocketClient>,
) -> Result<()>
pub fn subscribe( &self, id: InstrumentId, ws_client: Option<&KalshiWebSocketClient>, ) -> Result<()>
Adds one local subscription reference.
The first reference records WebSocket intent when ws_client is present. Later references
only increase demand.
§Errors
Returns an error if the WebSocket client rejects the subscription or the reference count overflows.
Sourcepub fn replay(&self, ws_client: &KalshiWebSocketClient) -> Result<()>
pub fn replay(&self, ws_client: &KalshiWebSocketClient) -> Result<()>
Restores book subscription intent and marks the session running.
§Errors
Returns an error if the WebSocket client rejects the retained subscription.
Sourcepub fn event(
&self,
event: &KalshiWsEvent,
instruments: &HashMap<InstrumentId, BinaryOption>,
sender: &EventSender<DataEvent>,
now: UnixNanos,
) -> Result<()>
pub fn event( &self, event: &KalshiWsEvent, instruments: &HashMap<InstrumentId, BinaryOption>, sender: &EventSender<DataEvent>, now: UnixNanos, ) -> Result<()>
Applies one book protocol event and sends any resulting deltas.
Ticker and trade frames are ignored. Events are ignored until Self::replay marks the
tracker running, and an older generation is ignored. A newer generation resets stream state
before the event is applied. Invalid snapshots and deltas gap the affected book and do not
emit a batch.
§Errors
Returns an error if the data receiver is closed.
Trait Implementations§
Source§impl Clone for BookSyncTracker
impl Clone for BookSyncTracker
Auto Trait Implementations§
impl Freeze for BookSyncTracker
impl RefUnwindSafe for BookSyncTracker
impl Send for BookSyncTracker
impl Sync for BookSyncTracker
impl Unpin for BookSyncTracker
impl UnsafeUnpin for BookSyncTracker
impl UnwindSafe for BookSyncTracker
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more