pub struct WsClient { /* private fields */ }Expand description
Handle to an open WebSocket connection.
Dropping the handle closes the connection.
The connection does not reconnect on its own.
Call WsClient::connect again and resubscribe when WsEvent::Closed
arrives.
Implementations§
Source§impl WsClient
impl WsClient
Sourcepub async fn connect(
config: ClientConfig,
) -> Result<(Self, UnboundedReceiver<WsEvent>)>
pub async fn connect( config: ClientConfig, ) -> Result<(Self, UnboundedReceiver<WsEvent>)>
Opens a connection and returns the client handle and the event stream.
Sourcepub async fn connect_public() -> Result<(Self, UnboundedReceiver<WsEvent>)>
pub async fn connect_public() -> Result<(Self, UnboundedReceiver<WsEvent>)>
Opens a connection with the default configuration for public channels.
Sourcepub fn authenticate(&self) -> Result<()>
pub fn authenticate(&self) -> Result<()>
Authenticates the connection.
Required before subscribing to the account channel.
The server confirms with WsEvent::Authenticated.
Sourcepub fn subscribe_ticker(&self, markets: &[&str]) -> Result<()>
pub fn subscribe_ticker(&self, markets: &[&str]) -> Result<()>
Subscribes to the ticker channel for the given markets.
Sourcepub fn subscribe_ticker_24h(&self, markets: &[&str]) -> Result<()>
pub fn subscribe_ticker_24h(&self, markets: &[&str]) -> Result<()>
Subscribes to the ticker24h channel for the given markets.
Sourcepub fn subscribe_trades(&self, markets: &[&str]) -> Result<()>
pub fn subscribe_trades(&self, markets: &[&str]) -> Result<()>
Subscribes to the trades channel for the given markets.
Sourcepub fn subscribe_candles(&self, markets: &[&str], interval: &str) -> Result<()>
pub fn subscribe_candles(&self, markets: &[&str], interval: &str) -> Result<()>
Subscribes to the candles channel for the given markets and interval.
Sourcepub fn subscribe_book(&self, markets: &[&str]) -> Result<()>
pub fn subscribe_book(&self, markets: &[&str]) -> Result<()>
Subscribes to the book channel for the given markets.
Sourcepub fn subscribe_account(&self, markets: &[&str]) -> Result<()>
pub fn subscribe_account(&self, markets: &[&str]) -> Result<()>
Subscribes to the account channel for the given markets.
Call WsClient::authenticate first and wait for
WsEvent::Authenticated.
Sourcepub fn unsubscribe(&self, channel: &str, markets: &[&str]) -> Result<()>
pub fn unsubscribe(&self, channel: &str, markets: &[&str]) -> Result<()>
Unsubscribes from a channel for the given markets.