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
subscribe to a set of assets
assets are lowercase, the gateway implementation is responsible for mapping names to the relevant exchange asset names
fn unsubscribe(&mut self, symbols: &[String])
fn unsubscribe(&mut self, symbols: &[String])
unsubscribe from a set of assets
fn on_websocket_message(&mut self, value: Value) -> Option<WsUpdate>
fn on_websocket_message(&mut self, value: Value) -> Option<WsUpdate>
handle a websocket message from exchange
fn ws_consumer(&self) -> WsConsumer
fn ws_consumer(&self) -> WsConsumer
return the websocket consumer for this gateway
Provided methods
fn request_snapshot(&mut self)
fn request_snapshot(&mut self)
Request book snapshots
fn on_book_snapshot(&mut self, _snapshot: BookSnapshot) -> Option<Book>
fn on_book_snapshot(&mut self, _snapshot: BookSnapshot) -> Option<Book>
handle a book snapshot