pub struct O2WebSocket { /* private fields */ }Expand description
WebSocket client for O2 Exchange real-time data.
Supports auto-reconnect, subscription tracking, heartbeat, and per-subscription channels for safe concurrent access.
Implementations§
Source§impl O2WebSocket
impl O2WebSocket
Sourcepub async fn connect_with_config(
url: &str,
config: WsConfig,
) -> Result<Self, O2Error>
pub async fn connect_with_config( url: &str, config: WsConfig, ) -> Result<Self, O2Error>
Connect with custom configuration.
Sourcepub fn subscribe_lifecycle(&self) -> Receiver<WsLifecycleEvent>
pub fn subscribe_lifecycle(&self) -> Receiver<WsLifecycleEvent>
Subscribe to lifecycle/reconnect events.
Sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Check if the WebSocket is currently connected.
Sourcepub async fn stream_depth(
&self,
market_id: &str,
precision: &DepthPrecision,
) -> Result<TypedStream<DepthUpdate>, O2Error>
pub async fn stream_depth( &self, market_id: &str, precision: &DepthPrecision, ) -> Result<TypedStream<DepthUpdate>, O2Error>
Subscribe to order book depth. Returns a stream of Result<DepthUpdate, O2Error>.
precision is a level index as a string (e.g. "1" for finest).
Valid range: "1"–"18". The SDK sends 10^precision on the wire,
matching the internal backend convention. All levels support live
delta streaming.
Note: Prefer [O2Client::stream_depth] which validates precision
and resolves market IDs by name.
Sourcepub async fn stream_orders(
&self,
identities: &[Identity],
) -> Result<TypedStream<OrderUpdate>, O2Error>
pub async fn stream_orders( &self, identities: &[Identity], ) -> Result<TypedStream<OrderUpdate>, O2Error>
Subscribe to order updates. Returns a stream of Result<OrderUpdate, O2Error>.
Sourcepub async fn stream_trades(
&self,
market_id: &str,
) -> Result<TypedStream<TradeUpdate>, O2Error>
pub async fn stream_trades( &self, market_id: &str, ) -> Result<TypedStream<TradeUpdate>, O2Error>
Subscribe to trades. Returns a stream of Result<TradeUpdate, O2Error>.
Sourcepub async fn stream_balances(
&self,
identities: &[Identity],
) -> Result<TypedStream<BalanceUpdate>, O2Error>
pub async fn stream_balances( &self, identities: &[Identity], ) -> Result<TypedStream<BalanceUpdate>, O2Error>
Subscribe to balance updates. Returns a stream of Result<BalanceUpdate, O2Error>.
Sourcepub async fn stream_nonce(
&self,
identities: &[Identity],
) -> Result<TypedStream<NonceUpdate>, O2Error>
pub async fn stream_nonce( &self, identities: &[Identity], ) -> Result<TypedStream<NonceUpdate>, O2Error>
Subscribe to nonce updates. Returns a stream of Result<NonceUpdate, O2Error>.
Sourcepub async fn unsubscribe_depth(&self, market_id: &str) -> Result<(), O2Error>
pub async fn unsubscribe_depth(&self, market_id: &str) -> Result<(), O2Error>
Unsubscribe from depth updates.
Sourcepub async fn unsubscribe_orders(&self) -> Result<(), O2Error>
pub async fn unsubscribe_orders(&self) -> Result<(), O2Error>
Unsubscribe from order updates.
Sourcepub async fn unsubscribe_trades(&self, market_id: &str) -> Result<(), O2Error>
pub async fn unsubscribe_trades(&self, market_id: &str) -> Result<(), O2Error>
Unsubscribe from trade updates.
Sourcepub async fn unsubscribe_balances(
&self,
identities: &[Identity],
) -> Result<(), O2Error>
pub async fn unsubscribe_balances( &self, identities: &[Identity], ) -> Result<(), O2Error>
Unsubscribe from balance updates.
Sourcepub async fn unsubscribe_nonce(
&self,
identities: &[Identity],
) -> Result<(), O2Error>
pub async fn unsubscribe_nonce( &self, identities: &[Identity], ) -> Result<(), O2Error>
Unsubscribe from nonce updates.
Sourcepub fn is_terminated(&self) -> bool
pub fn is_terminated(&self) -> bool
Check if the WebSocket has been permanently terminated (max reconnect attempts exhausted or explicitly stopped).
Sourcepub async fn disconnect(&self) -> Result<(), O2Error>
pub async fn disconnect(&self) -> Result<(), O2Error>
Close the WebSocket connection and stop all tasks.