document ws cancellation & delegation (#3786)

This commit is contained in:
Tim Vilgot Mikael Fredenberg
2026-06-05 09:21:16 +02:00
committed by GitHub
parent 4a72e063b9
commit ffe32473cc
+11
View File
@@ -549,11 +549,22 @@ impl WebSocket {
/// Receive another message.
///
/// Returns `None` if the stream has closed.
///
/// This method delegates to [`Stream`].
///
/// # Cancel safety
///
/// This method is cancel safe. If used as a branch in [`tokio::select!`] and
/// another branch completes first, then no message is received.
///
/// [`tokio::select!`]: https://docs.rs/tokio/latest/tokio/macro.select.html
pub async fn recv(&mut self) -> Option<Result<Message, Error>> {
self.next().await
}
/// Send a message.
///
/// This method delegates to [`Sink`].
pub async fn send(&mut self, msg: Message) -> Result<(), Error> {
self.inner
.send(msg.into_tungstenite())