pub async fn order_book_stream<M: OrderBookSource + ?Sized>(
md: &M,
rx: &mut Receiver<Envelope>,
source: &str,
id: &InstrumentId,
) -> SubscriptionIdExpand description
Order book stream: subscribe, then an order book envelope arrives tagged with our source and subscription id.
Subscribes with [brokapi_core::SubscribeOpts::conflate] and waits (up to EVENT_TIMEOUT) for the
first [brokapi_core::Event::OrderBook] envelope on rx. Checks that:
env.sourceequalssource(the label the connector was configured with);env.subis the id thatsubscribe_order_bookreturned;- the book is for the requested instrument.
Returns the subscription id and leaves the subscription open, so the caller can pass it to
unsubscribe. rx must be the receiver of the connector under test. Envelopes read before the
match are discarded. If an older order book subscription is still running on the same connector, its
book may arrive first and fail the sub check, so use a connector with no other book streams.
The mock must push at least one order book update after subscribe.
§Panics
With [conformance:order_book_stream] <reason> when the subscribe fails, when no order book arrives
(see next_matching), or when the source, subscription id or instrument is wrong.
§Examples
let sub = brokapi_conformance::order_book_stream(&md, &mut rx, "bcs-md", &sber).await;
brokapi_conformance::unsubscribe(&md, sub).await;