Struct barter_data::connection::ConnectionHandler[][src]

pub struct ConnectionHandler<Message, Sub> {
    pub ws_conn: WSStream,
    pub subscription_rx: Receiver<(Sub, UnboundedSender<Message>)>,
    pub exchange_data_txs: HashMap<StreamRoutingId, UnboundedSender<Message>>,
}
Expand description

Manages all connection related actions. This includes maintaining the WebSocket connection; re-connections; actioning Subscription requests received from an ExchangeClient; consuming incoming exchange messages from the WebSocket connection and routing them to the appropriate downstream consumer.

Fields

ws_conn: WSStream

An established WSStream connection that all ExchangeClient <–> ConnectionHandler communication goes through.

subscription_rx: Receiver<(Sub, UnboundedSender<Message>)>

Subscription request channel receiver. Receives a tuple of Subscription and a data channel transmitter. This data channel transmitter is used to route messages relating to a particular Subscription back to the subscriber via the ExchangeClient implementation.

exchange_data_txs: HashMap<StreamRoutingId, UnboundedSender<Message>>

Map containing the data channel transmitter for every Subscription actioned. The map’s StreamRoutingId key is used to identify which data channel to transmit an incoming exchange message to.

Implementations

Constructs a new ConnectionHandler instance using the WSStream connection provided.

Consumes two types of incoming messages Subscription requests received from an ExchangeClient implementor instance, and also the data received from an exchange as a result of a Subscription. This function handles the actioning of Subscription requests, and routes the exchange data to the associated downstream subscriber.

Subscribe asynchronously to a WebSocket data stream using the Subscription provided.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more