tokio-stream
Utilities for working with async streams (futures::Stream) in Tokio. Provides StreamExt trait for async-iterator-like operations (map, filter, take, collect, throttle, timeout), stream adapters (wrappers for channels, intervals, timeouts), and conversion utilities. The async equivalent of Rust's Iterator trait for Tokio-based applications.
Score Breakdown
⚙ Agent Friendliness
🔒 Security
Pure Rust async library — no network access. Memory-safe by Rust's ownership system.
⚡ Reliability
Best When
Working with async streams in Tokio applications and needing map/filter/throttle/timeout on async iterators.
Avoid When
You're not using Tokio or need complex reactive operators beyond map/filter/fold.
Use Cases
- • Process Tokio mpsc or broadcast channel receivers as async streams with StreamExt combinators
- • Implement per-stream rate limiting with throttle() or timeout handling with tokio_stream::StreamExt::timeout()
- • Convert any Iterator into an async Stream using tokio_stream::iter() for compatibility with async consumers
- • Build reactive data processing pipelines using async stream combinators (map, filter, flat_map, take_while)
- • Handle Server-Sent Events (SSE) or gRPC streaming responses as async streams in Axum/tonic services
Not For
- • Synchronous iteration — use Rust's standard Iterator for non-async code
- • Complex reactive programming patterns — async-stream or reactive-futures libraries offer more advanced operators
- • Non-tokio async runtimes — tokio-stream is optimized for Tokio; use async-std streams for async-std runtime
Interface
Authentication
Library — no auth needed.
Pricing
MIT licensed as part of the Tokio project.
Agent Metadata
Known Gotchas
- ⚠ Must use StreamExt from tokio_stream (not futures::StreamExt) to get tokio-specific combinators like timeout and throttle
- ⚠ Streams are lazy — nothing executes until polled with while let Some(x) = stream.next().await or collect::<Vec<_>>().await
- ⚠ timeout() wraps each item with Result<Item, Elapsed> — the outer stream never errors, individual items may be Err(Elapsed)
- ⚠ tokio-stream's wrappers for channels (ReceiverStream) require feature flags — enable 'sync' feature for channel stream wrappers
- ⚠ Streams implement Unpin or require Box::pin — moving a non-Unpin stream after creation will fail to compile; use Box::pin(stream) if ownership transfer is needed
- ⚠ StreamExt::collect() requires specifying the collection type: stream.collect::<Vec<_>>().await — type inference often fails without explicit annotation
Alternatives
Full Evaluation Report
Detailed scoring breakdown, competitive positioning, security analysis, and improvement recommendations for tokio-stream.
Scores are editorial opinions as of 2026-03-06.