pub struct WebsocketConnection { /* private fields */ }Expand description
A WebSocket connection with both blocking and async receive methods.
Implementations§
Source§impl WebsocketConnection
impl WebsocketConnection
Sourcepub fn connect(
url: &str,
headers: Option<Vec<(String, String)>>,
) -> Result<Self, Error>
pub fn connect( url: &str, headers: Option<Vec<(String, String)>>, ) -> Result<Self, Error>
Connect to a WebSocket server at the given URL (ws:// or wss://). Optional headers for auth, subprotocols, etc.
Sourcepub fn blocking_receive(&self) -> Result<Message, Error>
pub fn blocking_receive(&self) -> Result<Message, Error>
Receive the next message, blocking until one is available.
Sourcepub fn blocking_receive_with_timeout(
&self,
timeout_ms: u64,
) -> Result<Option<Message>, Error>
pub fn blocking_receive_with_timeout( &self, timeout_ms: u64, ) -> Result<Option<Message>, Error>
Receive the next message, blocking with a timeout in milliseconds.
Returns None if the timeout expires before a message arrives.
Auto Trait Implementations§
impl !Freeze for WebsocketConnection
impl RefUnwindSafe for WebsocketConnection
impl Send for WebsocketConnection
impl Sync for WebsocketConnection
impl Unpin for WebsocketConnection
impl UnsafeUnpin for WebsocketConnection
impl UnwindSafe for WebsocketConnection
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