pub struct WebSocketClient { /* private fields */ }Implementations§
Source§impl WebSocketClient
impl WebSocketClient
pub fn new() -> Self
pub fn is_connected(&self) -> bool
pub fn connect( &mut self, url: String, session_cookie: &str, ) -> Result<(), WebSocketError>
pub fn reconnect(&mut self) -> Result<(), WebSocketError>
Sourcepub fn send<I: Serialize>(&mut self, message: I) -> Result<(), WebSocketError>
pub fn send<I: Serialize>(&mut self, message: I) -> Result<(), WebSocketError>
Sends a message over the WebSocket connection. This is a non-blocking call. If sending fails, it attempts to reconnect and resend the message. Returns an error if both attempts fail.
Sourcepub fn receive<T: DeserializeOwned>(
&mut self,
) -> Result<Option<T>, WebSocketError>
pub fn receive<T: DeserializeOwned>( &mut self, ) -> Result<Option<T>, WebSocketError>
Attempts to receive a message from the WebSocket. This is a non-blocking call.
Returns Ok(None) if no message is available.
Sourcepub fn close(&mut self) -> Result<(), WebSocketError>
pub fn close(&mut self) -> Result<(), WebSocketError>
Closes the WebSocket connection gracefully. This is a non-blocking call.
Sourcepub fn wait_until_closed(&mut self) -> Result<(), WebSocketError>
pub fn wait_until_closed(&mut self) -> Result<(), WebSocketError>
Waits until the WebSocket connection is fully closed. This is a blocking call that will return once the connection is closed.
Trait Implementations§
Source§impl Default for WebSocketClient
impl Default for WebSocketClient
Source§fn default() -> WebSocketClient
fn default() -> WebSocketClient
Returns the “default value” for a type. Read more
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