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: WSStreamAn 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
impl<Message, Sub> ConnectionHandler<Message, Sub> where
Sub: Debug + Subscription + StreamIdentifier + Serialize + Send + Sync,
Message: Debug + StreamIdentifier + DeserializeOwned + Send + Sync,
impl<Message, Sub> ConnectionHandler<Message, Sub> where
Sub: Debug + Subscription + StreamIdentifier + Serialize + Send + Sync,
Message: Debug + StreamIdentifier + DeserializeOwned + Send + Sync,
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
impl<Message, Sub> !RefUnwindSafe for ConnectionHandler<Message, Sub>
impl<Message, Sub> Send for ConnectionHandler<Message, Sub> where
Message: Send,
Sub: Send,
impl<Message, Sub> Sync for ConnectionHandler<Message, Sub> where
Message: Send,
Sub: Send,
impl<Message, Sub> Unpin for ConnectionHandler<Message, Sub>
impl<Message, Sub> !UnwindSafe for ConnectionHandler<Message, Sub>
Blanket Implementations
Mutably borrows from an owned value. Read more
pub fn vzip(self) -> V
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