Skip to main content

WsDispatchState

Struct WsDispatchState 

Source
pub struct WsDispatchState { /* private fields */ }
Expand description

Shared dispatch state for the Derive WS execution loop.

Instrument precision populates from instrument definitions and governs execution report values. order_identities populates on successful submit_order and is consulted by both the .orders and .trades dispatch paths to decide whether a frame belongs to a tracked or external order. pending_modifies and bound_venue_order_ids track the in-flight and current venue order id of a private/replace so the dispatch suppresses events for the superseded leg.

Implementations§

Source§

impl WsDispatchState

Source

pub fn new() -> Self

Source

pub fn register_identity( &self, client_order_id: ClientOrderId, identity: OrderIdentity, )

Registers an order identity captured at submission so subsequent WS frames for the same client_order_id resolve to the tracked path.

Source

pub fn identity(&self, client_order_id: &ClientOrderId) -> Option<OrderIdentity>

Returns the registered identity for a client order, when one was captured at submission time.

Source

pub fn forget(&self, client_order_id: &ClientOrderId)

Drops identity and the accepted marker for a terminal order so future stale frames (post-cancel cleanup, history backfill) take the untracked report path.

Source

pub fn record_venue_order_id( &self, client_order_id: ClientOrderId, venue_order_id: VenueOrderId, )

Records the venue order id currently bound to a tracked client order.

Source

pub fn bound_venue_order_id( &self, client_order_id: &ClientOrderId, ) -> Option<VenueOrderId>

Returns the venue order id currently bound to a tracked client order.

Source

pub fn mark_pending_modify( &self, client_order_id: ClientOrderId, old_venue_order_id: VenueOrderId, )

Records the old venue order id of an in-flight private/replace, set before the request so the cancel leg is suppressed.

Source

pub fn clear_pending_modify(&self, client_order_id: &ClientOrderId)

Clears the in-flight modify marker once the replace resolves.

Source

pub fn pending_modify( &self, client_order_id: &ClientOrderId, ) -> Option<VenueOrderId>

Returns the old venue order id of an in-flight modify, when one is set.

Source

pub fn bind_incoming_modify( &self, client_order_id: ClientOrderId, venue_order_id: VenueOrderId, terminal: bool, ) -> bool

Rebinds an in-flight modify when a frame for its replacement arrives before the private/replace response.

Source

pub fn take_pending_modify( &self, client_order_id: &ClientOrderId, old_venue_order_id: VenueOrderId, new_venue_order_id: Option<VenueOrderId>, ) -> bool

Atomically claims a pending modify for its RPC response, optionally rebinding the replacement venue order id before clearing the marker. Returns false when an incoming terminal frame already resolved it.

Source

pub fn contains_accepted(&self, client_order_id: &ClientOrderId) -> bool

Returns true when an OrderAccepted has already been emitted for this client order in the current process lifetime.

Source

pub fn mark_accepted(&self, client_order_id: ClientOrderId) -> bool

Records that OrderAccepted has been emitted for this client order. Returns true when the marker was already present (duplicate).

Source

pub fn mark_canceled(&self, client_order_id: ClientOrderId) -> bool

Records that OrderCanceled has been emitted for this client order. Returns true when the marker was already present (duplicate).

Source

pub fn contains_filled(&self, client_order_id: &ClientOrderId) -> bool

Returns true when this client order has reached a terminal filled state, used to suppress stale Accepted frames replayed on reconnect.

Source

pub fn mark_filled(&self, client_order_id: ClientOrderId)

Marks the client order as terminally filled. Idempotent.

Source

pub fn check_and_insert_trade(&self, trade_id: TradeId) -> bool

Inserts the trade id atomically. Returns true when the id was already present (i.e., this fill should be skipped as a duplicate).

Source

pub fn contains_trade(&self, trade_id: &TradeId) -> bool

Returns true when this trade id has already been seen, without mutating state.

Trait Implementations§

Source§

impl Debug for WsDispatchState

Source§

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

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

impl Default for WsDispatchState

Source§

fn default() -> WsDispatchState

Returns the “default value” for a type. 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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

impl<T> Ungil for T
where T: Send,

§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more