pub struct WebSocketClient { /* private fields */ }Expand description
WebSocket client for connecting to Binance streams.
Implementations§
Source§impl WebSocketClient
impl WebSocketClient
Sourcepub async fn connect(&self, stream: &str) -> Result<WebSocketConnection>
pub async fn connect(&self, stream: &str) -> Result<WebSocketConnection>
Sourcepub async fn connect_combined(
&self,
streams: &[String],
) -> Result<WebSocketConnection>
pub async fn connect_combined( &self, streams: &[String], ) -> Result<WebSocketConnection>
Sourcepub async fn connect_user_stream(
&self,
listen_key: &str,
) -> Result<WebSocketConnection>
pub async fn connect_user_stream( &self, listen_key: &str, ) -> Result<WebSocketConnection>
Sourcepub async fn connect_with_reconnect(
&self,
stream: &str,
) -> Result<ReconnectingWebSocket>
pub async fn connect_with_reconnect( &self, stream: &str, ) -> Result<ReconnectingWebSocket>
Connect with auto-reconnection support.
Returns a ReconnectingWebSocket that automatically reconnects on
disconnection with exponential backoff.
§Arguments
stream- Stream name (e.g., “btcusdt@aggTrade”)
§Example
let ws = client.websocket();
let stream = ws.agg_trade_stream("btcusdt");
let mut conn = ws.connect_with_reconnect(&stream).await?;
// Connection will auto-reconnect on failure
while let Some(event) = conn.next().await {
println!("{:?}", event?);
}Sourcepub async fn connect_combined_with_reconnect(
&self,
streams: &[String],
) -> Result<ReconnectingWebSocket>
pub async fn connect_combined_with_reconnect( &self, streams: &[String], ) -> Result<ReconnectingWebSocket>
Connect to combined streams with auto-reconnection support.
Sourcepub fn agg_trade_stream(&self, symbol: &str) -> String
pub fn agg_trade_stream(&self, symbol: &str) -> String
Get the aggregate trade stream name for a symbol.
Stream: <symbol>@aggTrade
Sourcepub fn trade_stream(&self, symbol: &str) -> String
pub fn trade_stream(&self, symbol: &str) -> String
Get the trade stream name for a symbol.
Stream: <symbol>@trade
Sourcepub fn kline_stream(&self, symbol: &str, interval: KlineInterval) -> String
pub fn kline_stream(&self, symbol: &str, interval: KlineInterval) -> String
Get the kline/candlestick stream name for a symbol.
Stream: <symbol>@kline_<interval>
Sourcepub fn mini_ticker_stream(&self, symbol: &str) -> String
pub fn mini_ticker_stream(&self, symbol: &str) -> String
Get the mini ticker stream name for a symbol.
Stream: <symbol>@miniTicker
Sourcepub fn all_mini_ticker_stream(&self) -> String
pub fn all_mini_ticker_stream(&self) -> String
Get the mini ticker stream for all symbols.
Stream: !miniTicker@arr
Sourcepub fn ticker_stream(&self, symbol: &str) -> String
pub fn ticker_stream(&self, symbol: &str) -> String
Get the 24hr ticker stream name for a symbol.
Stream: <symbol>@ticker
Sourcepub fn all_ticker_stream(&self) -> String
pub fn all_ticker_stream(&self) -> String
Get the 24hr ticker stream for all symbols.
Stream: !ticker@arr
Sourcepub fn book_ticker_stream(&self, symbol: &str) -> String
pub fn book_ticker_stream(&self, symbol: &str) -> String
Get the book ticker stream name for a symbol.
Stream: <symbol>@bookTicker
Sourcepub fn all_book_ticker_stream(&self) -> String
pub fn all_book_ticker_stream(&self) -> String
Get the book ticker stream for all symbols.
Stream: !bookTicker
Sourcepub fn partial_depth_stream(
&self,
symbol: &str,
levels: u8,
fast: bool,
) -> String
pub fn partial_depth_stream( &self, symbol: &str, levels: u8, fast: bool, ) -> String
Get the partial book depth stream name.
Stream: <symbol>@depth<levels> or <symbol>@depth<levels>@100ms
§Arguments
symbol- Trading pair symbollevels- Depth levels (5, 10, or 20)fast- If true, use 100ms update speed instead of 1000ms
Trait Implementations§
Source§impl Clone for WebSocketClient
impl Clone for WebSocketClient
Source§fn clone(&self) -> WebSocketClient
fn clone(&self) -> WebSocketClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more