pub struct WebSocketClient { /* private fields */ }Expand description
Async WebSocket client — manages connection lifecycle and reconnection (BR-006, BR-007).
Implementations§
Source§impl WebSocketClient
impl WebSocketClient
Sourcepub fn new(base_url: &str) -> Result<Self, AsterDexError>
pub fn new(base_url: &str) -> Result<Self, AsterDexError>
Construct a new WebSocket client.
Sourcepub fn with_reconnect_config(self, cfg: ReconnectConfig) -> Self
pub fn with_reconnect_config(self, cfg: ReconnectConfig) -> Self
Builder method: set a custom reconnect configuration.
Sourcepub async fn subscribe(
&self,
streams: Vec<&str>,
) -> Result<WebSocketStream, AsterDexError>
pub async fn subscribe( &self, streams: Vec<&str>, ) -> Result<WebSocketStream, AsterDexError>
Subscribe to market data streams (combined stream endpoint).
§Errors
WebSocketError("at least one stream name required")ifstreamsis empty.WebSocketError("max 200 streams per connection")if > 200 streams.WebSocketError("connection failed: …")if the initial connection fails.
Sourcepub async fn unsubscribe(
_stream: &mut WebSocketStream,
_streams: Vec<&str>,
) -> Result<(), AsterDexError>
pub async fn unsubscribe( _stream: &mut WebSocketStream, _streams: Vec<&str>, ) -> Result<(), AsterDexError>
Unsubscribe from specific streams on an active connection.
Not yet supported — drop the WebSocketStream to close the connection.
Sourcepub async fn subscribe_user_data(
&self,
listen_key: &str,
) -> Result<UserDataStream, AsterDexError>
pub async fn subscribe_user_data( &self, listen_key: &str, ) -> Result<UserDataStream, AsterDexError>
Subscribe to the user data stream using a listen key.
§Errors
WebSocketError("user data stream connection failed: …")if the initial connection fails.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for WebSocketClient
impl RefUnwindSafe for WebSocketClient
impl Send for WebSocketClient
impl Sync for WebSocketClient
impl Unpin for WebSocketClient
impl UnsafeUnpin for WebSocketClient
impl UnwindSafe for WebSocketClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more