Skip to main content

unsubscribe

Function unsubscribe 

Source
pub async fn unsubscribe<M: OrderBookSource + ?Sized>(
    md: &M,
    sub: SubscriptionId,
)
Expand description

Unsubscribing an active subscription succeeds, and doing it again is refused the same way at every broker.

The first call must return Ok. The second call, for an id that is already closed, must return [Error::Rejected] with code unknown_subscription: not Ok, not a transport error, not a panic. sub is the id of a live subscription, for example the one order_book_stream returned.

§Panics

With [conformance:unsubscribe] ... when the first call returns an error, or the second one is not the refusal described above.

§Examples

let sub = brokapi_conformance::order_book_stream(&md, &mut rx, "bcs-md", &sber).await;
brokapi_conformance::unsubscribe(&md, sub).await;