pub struct MarketRegistry { /* private fields */ }Expand description
Registry mapping market_index to InstrumentId and back.
Indexed for O(1) lookup by all three keys the adapter switches between:
the venue’s numeric market_index (used in transaction encoding and
WebSocket subscriptions), the Nautilus [InstrumentId] (used by the
engine), and the raw venue symbol scoped by product type (used when
parsing REST list responses). Designed to be shared across the HTTP and
WebSocket clients via Arc.
The registry is intended for write-once bootstrap followed by read-only
consumption: each individual lookup is lock-free, but a single insert
is not transactional across the three indexes. Rare write events such
as relists must be coordinated by the caller (e.g. quiesce consumers
before reinserting) to avoid concurrent readers observing partial
state.
Implementations§
Source§impl MarketRegistry
impl MarketRegistry
Sourcepub fn insert(
&self,
market_index: i16,
venue_symbol: &str,
product_type: LighterProductType,
) -> InstrumentId
pub fn insert( &self, market_index: i16, venue_symbol: &str, product_type: LighterProductType, ) -> InstrumentId
Registers a market and returns the resulting [InstrumentId].
Re-inserting the same market_index overwrites the previous mapping;
callers may use this to handle venue rename or relisting events. Stale
entries in the inverse indexes are evicted before the new mapping is
installed so all three lookups stay consistent.
Sourcepub fn instrument_id(&self, market_index: i16) -> Option<InstrumentId>
pub fn instrument_id(&self, market_index: i16) -> Option<InstrumentId>
Returns the [InstrumentId] for a given market_index.
Sourcepub fn all_market_indices(&self) -> Vec<i16>
pub fn all_market_indices(&self) -> Vec<i16>
Returns every registered market_index.
Callers iterating across all venue markets (e.g. the mass-status reconciliation path) use this to bound the per-market REST fan-out.
Sourcepub fn market_index(&self, instrument_id: &InstrumentId) -> Option<i16>
pub fn market_index(&self, instrument_id: &InstrumentId) -> Option<i16>
Returns the venue market_index for a given [InstrumentId].
Sourcepub fn instrument_id_by_symbol(
&self,
venue_symbol: &str,
product_type: LighterProductType,
) -> Option<InstrumentId>
pub fn instrument_id_by_symbol( &self, venue_symbol: &str, product_type: LighterProductType, ) -> Option<InstrumentId>
Returns the [InstrumentId] for a raw venue symbol scoped by product.
The raw symbol on its own is ambiguous when the venue lists the same asset on both perpetual and spot; the product discriminant resolves it.
Trait Implementations§
Source§impl Debug for MarketRegistry
impl Debug for MarketRegistry
Source§impl Default for MarketRegistry
impl Default for MarketRegistry
Source§fn default() -> MarketRegistry
fn default() -> MarketRegistry
Auto Trait Implementations§
impl !RefUnwindSafe for MarketRegistry
impl Freeze for MarketRegistry
impl Send for MarketRegistry
impl Sync for MarketRegistry
impl Unpin for MarketRegistry
impl UnsafeUnpin for MarketRegistry
impl UnwindSafe for MarketRegistry
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>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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