pub struct WebSocket { /* private fields */ }Expand description
An upgraded connection
Implementations§
Source§impl WebSocket
impl WebSocket
Sourcepub async fn recv(&mut self) -> Option<Result<Message>>
pub async fn recv(&mut self) -> Option<Result<Message>>
Next message, or None once the connection is closed (by either side, or
because the peer went silent for WsOptions::idle_timeout)
Keep-alive pings are sent from inside this call, so a handler should
spend most of its time waiting here (or in a select! that includes it).
Sourcepub async fn send_json<T: Serialize>(&mut self, value: &T) -> Result<()>
pub async fn send_json<T: Serialize>(&mut self, value: &T) -> Result<()>
Send value as a JSON text message
Sourcepub async fn close_with(&mut self, code: u16, reason: &str) -> Result<()>
pub async fn close_with(&mut self, code: u16, reason: &str) -> Result<()>
Close with a status code (e.g. 1008 policy violation, 1009 message too big, 1001 going away) and a short reason
pub async fn send(&mut self, message: Message) -> Result<()>
pub async fn send_text(&mut self, text: impl Into<String>) -> Result<()>
pub async fn send_binary(&mut self, data: impl Into<Vec<u8>>) -> Result<()>
Auto Trait Implementations§
impl !Freeze for WebSocket
impl !RefUnwindSafe for WebSocket
impl !Sync for WebSocket
impl !UnwindSafe for WebSocket
impl Send for WebSocket
impl Unpin for WebSocket
impl UnsafeUnpin for WebSocket
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