-
I'm having trouble understanding how that example : use axum::{Error, extract::ws::{WebSocket, Message}};
use futures_util::{sink::SinkExt, stream::{StreamExt, SplitSink, SplitStream}};
async fn handle_socket(mut socket: WebSocket) {
let (mut sender, mut receiver) = socket.split();
tokio::spawn(write(sender));
tokio::spawn(read(receiver));
}
async fn read(receiver: SplitStream<WebSocket>) {
// ...
}
async fn write(sender: SplitSink<WebSocket, Message>) {
// ...
} can work in practice : "SplitStream".next() needs mutable borrow, which doesn't seem to be possible, even when trying to change the "async fn read" signature. The solution i found would be to use something like an |
Beta Was this translation helpful? Give feedback.
Answered by
jplatte
May 28, 2025
Replies: 1 comment 5 replies
-
What problem were you running into when adding |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why
receiver: &mut SplitStream<WebSocket>
? Trymut receiver: SplitStream<WebSocket>
.