From ffe32473ccd5e7dfa08aa5fde63d42c980377b53 Mon Sep 17 00:00:00 2001 From: Tim Vilgot Mikael Fredenberg <26655508+vilgotf@users.noreply.github.com> Date: Fri, 5 Jun 2026 09:21:16 +0200 Subject: [PATCH] document ws cancellation & delegation (#3786) --- axum/src/extract/ws.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/axum/src/extract/ws.rs b/axum/src/extract/ws.rs index 2eb3b2af..d9e7adcd 100644 --- a/axum/src/extract/ws.rs +++ b/axum/src/extract/ws.rs @@ -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> { 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())