External Publication
Visit Post

Going from AsyncWrite to AsyncRead

Rust Internals [Unofficial] April 11, 2026
Source

I've seen and used ReaderStreamsucessfully together with axum. Unfortunately, the tokio-dependency is a showstopper since the code is used in the Browser too for uploads... But AsyncReadStream<Item=Bytes> is rather simple and was discussed in futures-util already (issue)

I have not seen a helper in tokio-util, which allows writing to a AsyncWrite to get a AsyncRead... I need that to write to AsyncZipWriter.... In the first attempt, i used ReaderStream with a tokio free alternative of tokio_util::io::simplex and spawned a background task to fill the Writer... But this involves spawning a Task, using a Queue and its a mess, to correctly handle io-Errors in the spawned Task correctly… Use of ? there is almost certainly wrong, as we need to Kill the connection, so the receiver knows, that things went south and doesn’t just get EOF…

With the proposed util, it could be implemented runtime independent, without allocations and even without locking or Atomics, which should enable aggressive compiler optimizations… Such encoders (what they basically are) could even be used in no-std/no-alloc environments

The cool thing about this abstraction is, that polling the stream also drives the future if progress should be made…

Discussion in the ATmosphere

Loading comments...