Skip to main content

Subscriber

Trait Subscriber 

Source
pub trait Subscriber:
    Clone
    + Send
    + Sync {
    type SubMapper: SubscriptionMapper;
    type Transport: Send;

    // Required method
    fn subscribe<Exchange, Instrument, Kind>(
        &self,
        subscriptions: &[Subscription<Exchange, Instrument, Kind>],
    ) -> impl Future<Output = Result<Subscribed<Instrument::Key, Self::Transport>, SocketError>> + Send
       where Exchange: Connector + Send + Sync,
             Kind: SubscriptionKind + Send + Sync,
             Instrument: InstrumentData,
             Subscription<Exchange, Instrument, Kind>: Identifier<Exchange::Channel> + Identifier<Exchange::Market>;
}
Expand description

Defines how to connect to a socket and subscribe to market data streams.

Subscribers may carry state such as authentication credentials. The trait requires Clone to support reconnection (subscribers are cloned into the reconnect closure).

Required Associated Types§

Source

type SubMapper: SubscriptionMapper

Source

type Transport: Send

What a successful subscribe hands the stream to read from.

A WebSocket of its own for almost every exchange, and the only transport the standard MarketStream initialisation accepts. A subscriber whose streams share one connection instead hands out a per-stream view of it, and pairs with a MarketStream of its own that knows how to read that view.

Send, because a stream’s transport is moved into the task that drives it.

Required Methods§

Source

fn subscribe<Exchange, Instrument, Kind>( &self, subscriptions: &[Subscription<Exchange, Instrument, Kind>], ) -> impl Future<Output = Result<Subscribed<Instrument::Key, Self::Transport>, SocketError>> + Send
where Exchange: Connector + Send + Sync, Kind: SubscriptionKind + Send + Sync, Instrument: InstrumentData, Subscription<Exchange, Instrument, Kind>: Identifier<Exchange::Channel> + Identifier<Exchange::Market>,

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§