External Publication
Visit Post

Going from AsyncWrite to AsyncRead

Rust Internals [Unofficial] April 11, 2026
Source

What do you mean, by ‘stop executing’? E.g. returning Poll::Pending because of a Mutex? The future at position 1 can still continue, right? Or is the problem, that some_other_async might not continue for some time untill there is space?

Edit: Or did you mean, that, if future1 returns io::Error, future2 doesn’t continue? This is not possible with join, since the Error of future_1 can only be propagated, when some_other_async finishes too…

Did you think about this? ```

let other = std::pin::pin!(some_other_async());
let stream = Stream::new(|w: Writer| async move {
    tokio::join!(async {
        let mut w = std::pin::pin!(w);
        write_all(&mut w, &[42]).await?;
        write_all(w, &[42]).await
    }, async {
        other.await;
    });
});
consume(stream).await;
/// Here, other could not be unfinished, even if there is still a ref available

If we just make sure, that we always finish the future which is given into Stream::new, we should be good… In contrast if it were a Sender::Item=Result<(), io::Error>, the future doens’t have the possibility to send a Std::err and not be done… It can only finish via Err(io::Error) to propagate errors…

Discussion in the ATmosphere

Loading comments...