pub struct WsReceiver { /* private fields */ }Expand description
Owning receive-half of a WebSocket connection (bd:JMAP-6r7c.31).
Returned from WsSession::split. Holds the underlying tungstenite
stream and exposes next_frame. See
WsSender for the companion type and the concurrency rationale.
Implementations§
Source§impl WsReceiver
impl WsReceiver
Sourcepub async fn next_frame(&mut self) -> Option<Result<WsFrame, ClientError>>
pub async fn next_frame(&mut self) -> Option<Result<WsFrame, ClientError>>
Receive the next parsed frame from the server.
Returns None when the server has cleanly closed the connection.
Returns Some(Err(...)) on parse failure, transport error, RFC 8887
§4.1 violation (Binary frame), or starvation cap (more than 64
consecutive Ping/Pong/Frame messages — see the private
MAX_CONSECUTIVE_NON_TEXT_FRAMES constant for the exact value).
After a transport error the connection is broken and next_frame
must not be called again. After an UnexpectedResponse error the
underlying stream is still healthy — the caller may choose to
ignore it and retry, or to disconnect.