pub trait Gateway {
    fn name(&self) -> &str;
    fn subscribe(&mut self, symbols: &[String]);
    fn unsubscribe(&mut self, symbols: &[String]);
    fn on_websocket_message(&mut self, value: Value) -> Option<WsUpdate>;
    fn ws_consumer(&self) -> WsConsumer;

    fn setup(&self) { ... }
    fn request_snapshot(&mut self) { ... }
    fn on_book_snapshot(&mut self, _snapshot: BookSnapshot) -> Option<Book> { ... }
}
Expand description

A Gateway trait

A gateway implements the middleware for connecting to remote crypto exchanges and parse orderbook (or other) messages in a streaming fashion.

Required methods

gateway name

subscribe to a set of assets

assets are lowercase, the gateway implementation is responsible for mapping names to the relevant exchange asset names

unsubscribe from a set of assets

handle a websocket message from exchange

return the websocket consumer for this gateway

Provided methods

Request book snapshots

handle a book snapshot

Implementors