pub struct WebSocketStream<S> { /* private fields */ }Expand description
A bounded, message-oriented RFC 6455 stream.
Implementations§
Source§impl<S: AsyncRead + AsyncWrite + Unpin> WebSocketStream<S>
impl<S: AsyncRead + AsyncWrite + Unpin> WebSocketStream<S>
Sourcepub async fn recv_message(&mut self) -> Result<Vec<u8>>
pub async fn recv_message(&mut self) -> Result<Vec<u8>>
Receive the next complete binary message.
Ping frames are answered with pong frames and are not returned. Text, continuation, fragmented, reserved-bit and unmasked client frames are rejected, and non-minimal payload lengths are invalid. A close frame or any frame I/O error transitions the stream to a terminal state; a partially consumed or written frame is never retried on the same stream.
§Errors
Returns malformed-frame, timeout, connection, or write failures.
Sourcepub async fn send_binary(&mut self, payload: &[u8]) -> Result<()>
pub async fn send_binary(&mut self, payload: &[u8]) -> Result<()>
Send one unfragmented binary message to the peer.
A frame I/O error or timeout transitions the stream to a terminal state because a partial write cannot be retried without duplicating bytes.
§Errors
Returns a size, timeout, connection, or write failure.
Auto Trait Implementations§
impl<S> Freeze for WebSocketStream<S>where
S: Freeze,
impl<S> RefUnwindSafe for WebSocketStream<S>where
S: RefUnwindSafe,
impl<S> Send for WebSocketStream<S>where
S: Send,
impl<S> Sync for WebSocketStream<S>where
S: Sync,
impl<S> Unpin for WebSocketStream<S>where
S: Unpin,
impl<S> UnsafeUnpin for WebSocketStream<S>where
S: UnsafeUnpin,
impl<S> UnwindSafe for WebSocketStream<S>where
S: UnwindSafe,
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