The async ecosystem in rust isn’t fully developed yet and in a somewhat experimental/unstable stage.
Specifically, there’s no consensus yet on the trait used for streaming bytes.
Mainly, there exists tokio’s AsyncRead
and future-rs’s future::io::AsyncRead
.
This is a link aggregation on related information:
Various traits & code
- AsyncRead in tokio::io - Rust
- AsyncRead in futures::io - Rust
- Read in async_std::io - Rust
- AsyncRead in smol::io - Rust
Supposedly the traits in futures
, async_std
and smol
are the same.
Supposedly the futures
trait is the most likely to make it into rust’s std
library.
The changes in tokio’s AsyncRead
also apply to rust std’s Read
trait, so may make it into std together at a later point in time.
To actually see what you can do with these traits, look for the -Ext
variants (e.g. AsyncReadExt
), similar to how Stream
has StreamExt
.
tokio_util::compat - Rust is a compatibility trait for these tokio-based traits and the others.
History
These are some PR/issue links I picked up along the way, sorted by time from oldest to most recent.
- Proposing new `AsyncRead` / `AsyncWrite` traits by seanmonstar · Pull Request #1744 · tokio-rs/tokio · GitHub
- Add AsyncRead::poll_read_buf and AsyncWrite::poll_write_buf by taiki-e · Pull Request #1826 · rust-lang/futures-rs · GitHub
- io: propose new AsyncRead / AsyncWrite traits · Issue #2716 · tokio-rs/tokio · GitHub
- AsyncRead, AsyncWrite traits · Issue #23 · rust-lang/wg-async · GitHub
Discussions
- Blog post/Interview with proponent of tokio-style AsyncRead: Baby Steps
- Performance analysis: Tokio AsyncRead / AsyncWrite - HackMD
- Async read and write traits (more recent)
- Reddit “strategies for
futures::io::AsyncRead
vs.tokio::io::AsyncRead
” - Reddit "futures and tokio (and async-std) having duplicate traits and functionality?