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
impl WsDispatchState
pub fn new() -> Self
Sourcepub fn register_identity(
&self,
client_order_id: ClientOrderId,
identity: OrderIdentity,
)
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.
Sourcepub fn identity(&self, client_order_id: &ClientOrderId) -> Option<OrderIdentity>
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.
Sourcepub fn forget(&self, client_order_id: &ClientOrderId)
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.
Sourcepub fn record_venue_order_id(
&self,
client_order_id: ClientOrderId,
venue_order_id: VenueOrderId,
)
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.
Sourcepub fn bound_venue_order_id(
&self,
client_order_id: &ClientOrderId,
) -> Option<VenueOrderId>
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.
Sourcepub fn mark_pending_modify(
&self,
client_order_id: ClientOrderId,
old_venue_order_id: VenueOrderId,
)
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.
Sourcepub fn clear_pending_modify(&self, client_order_id: &ClientOrderId)
pub fn clear_pending_modify(&self, client_order_id: &ClientOrderId)
Clears the in-flight modify marker once the replace resolves.
Sourcepub fn pending_modify(
&self,
client_order_id: &ClientOrderId,
) -> Option<VenueOrderId>
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.
Sourcepub fn bind_incoming_modify(
&self,
client_order_id: ClientOrderId,
venue_order_id: VenueOrderId,
terminal: bool,
) -> bool
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.
Sourcepub fn take_pending_modify(
&self,
client_order_id: &ClientOrderId,
old_venue_order_id: VenueOrderId,
new_venue_order_id: Option<VenueOrderId>,
) -> bool
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.
Sourcepub fn contains_accepted(&self, client_order_id: &ClientOrderId) -> bool
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.
Sourcepub fn mark_accepted(&self, client_order_id: ClientOrderId) -> bool
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).
Sourcepub fn mark_canceled(&self, client_order_id: ClientOrderId) -> bool
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).
Sourcepub fn contains_filled(&self, client_order_id: &ClientOrderId) -> bool
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.
Sourcepub fn mark_filled(&self, client_order_id: ClientOrderId)
pub fn mark_filled(&self, client_order_id: ClientOrderId)
Marks the client order as terminally filled. Idempotent.
Sourcepub fn check_and_insert_trade(&self, trade_id: TradeId) -> bool
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).
Sourcepub fn contains_trade(&self, trade_id: &TradeId) -> bool
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
impl Debug for WsDispatchState
Source§impl Default for WsDispatchState
impl Default for WsDispatchState
Source§fn default() -> WsDispatchState
fn default() -> WsDispatchState
Auto Trait Implementations§
impl !Freeze for WsDispatchState
impl !RefUnwindSafe for WsDispatchState
impl Send for WsDispatchState
impl Sync for WsDispatchState
impl Unpin for WsDispatchState
impl UnsafeUnpin for WsDispatchState
impl UnwindSafe for WsDispatchState
Blanket Implementations§
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
§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