pub struct WebSocketClient { /* private fields */ }Expand description
WebSocket client
Implementations§
Source§impl WebSocketClient
impl WebSocketClient
Sourcepub fn new(config: WebSocketConfig) -> Self
pub fn new(config: WebSocketConfig) -> Self
Create a new WebSocket client
Sourcepub async fn run<H: MessageHandler + 'static>(
&mut self,
handler: H,
) -> WebSocketResult<()>
pub async fn run<H: MessageHandler + 'static>( &mut self, handler: H, ) -> WebSocketResult<()>
Connect and run the client with a message handler
Sourcepub async fn send(&self, message: Message) -> WebSocketResult<()>
pub async fn send(&self, message: Message) -> WebSocketResult<()>
Send a message (high-performance, non-blocking)
Sourcepub fn try_send(&self, message: Message) -> bool
pub fn try_send(&self, message: Message) -> bool
Try to send a message (non-blocking, returns false if channel is full)
Sourcepub fn state(&self) -> ConnectionState
pub fn state(&self) -> ConnectionState
Get the current connection state
Sourcepub fn stats(&self) -> ClientStats
pub fn stats(&self) -> ClientStats
Get statistics
Auto Trait Implementations§
impl !Freeze for WebSocketClient
impl !RefUnwindSafe for WebSocketClient
impl Send for WebSocketClient
impl Sync for WebSocketClient
impl Unpin 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