pub trait OrderBookWebSocket: Send + Sync {
// Required methods
async fn connect(&mut self) -> Result<(), WebSocketError>;
async fn disconnect(&mut self) -> Result<(), WebSocketError>;
async fn subscribe(
&mut self,
market_ticker: &str,
) -> Result<(), WebSocketError>;
async fn unsubscribe(
&mut self,
market_ticker: &str,
) -> Result<(), WebSocketError>;
fn state(&self) -> WebSocketState;
fn updates(&self) -> Option<UpdateStream>;
fn session_events(&self) -> Option<SessionStream>;
}Expand description
WebSocket driver trait. Surface is deliberately small: connect/disconnect, subscribe/unsubscribe per market, and hand out two multiplexed streams.
updates() carries per-market book and activity events; session_events()
carries connection-level signals that a consumer wants to observe exactly
once regardless of how many markets are subscribed.
Both stream methods are take-once: subsequent calls return None. The
underlying channel is single-consumer by contract — handing out cloned
receivers would split messages silently between holders, so a second
“debug sidecar” consumer is rejected at the call site instead. For
fan-out, run one consumer that re-dispatches.
Required Methods§
async fn connect(&mut self) -> Result<(), WebSocketError>
async fn disconnect(&mut self) -> Result<(), WebSocketError>
async fn subscribe(&mut self, market_ticker: &str) -> Result<(), WebSocketError>
async fn unsubscribe( &mut self, market_ticker: &str, ) -> Result<(), WebSocketError>
fn state(&self) -> WebSocketState
Sourcefn updates(&self) -> Option<UpdateStream>
fn updates(&self) -> Option<UpdateStream>
Take ownership of the multiplexed update stream. Returns None if
already taken.
Sourcefn session_events(&self) -> Option<SessionStream>
fn session_events(&self) -> Option<SessionStream>
Take ownership of the connection-level session event stream. Returns
None if already taken.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.