Expand description
Async stream processing primitives.
This module provides the Stream trait and related combinators for
processing asynchronous sequences of values.
§Core Traits
Stream: The async equivalent ofIterator, producing values over timeStreamExt: Extension trait providing combinator methods
§Combinators
§Transformation
Map: Transforms each item with a closureFilter: Yields only items matching a predicateFilterMap: Combines filter and map in one stepThen: Async map (runs future per item)Enumerate: Adds index to itemsInspect: Runs closure on items without consuming
§Selection
Take: Limits stream to n itemsTakeWhile: Limits stream while predicate is trueSkip: Skips n itemsSkipWhile: Skips while predicate is trueFuse: Fuses the stream
§Combination
Chain: Yields all items from one stream then anotherZip: Pairs items from two streamsMerge: Interleaves items from multiple streams
§Stateful
Scan: Yields intermediate accumulator values (likeIterator::scan)Peekable: Look at the next item without consuming it
§Rate Control
Throttle: Rate-limits to at most one item per periodDebounce: Suppresses rapid bursts, yielding after a quiet period
§Buffering
Buffered: Runs multiple futures while preserving orderBufferUnordered: Runs multiple futures without ordering guaranteesChunks: Groups items into fixed-size batchesReadyChunks: Returns immediately available items
§Terminal Operations
Collect: Collects all items into a collectionFold: Reduces items into a single valueForEach: Executes a closure for each itemCount: Counts the number of itemsAny: Checks if any item matches a predicateAll: Checks if all items match a predicate
§Error Handling
TryCollect: Collects items from a stream of ResultsTryFold: Folds a stream of ResultsTryForEach: Executes a fallible closure for each item
§Examples
ⓘ
use asupersync::stream::{iter, StreamExt};
async fn example() {
let sum = iter(vec![1, 2, 3, 4, 5])
.filter(|x| *x % 2 == 0)
.map(|x| x * 2)
.fold(0, |acc, x| acc + x)
.await;
assert_eq!(sum, 12); // (2*2) + (4*2) = 12
}Structs§
- All
- A future that checks if all items in a stream match a predicate.
- Any
- A future that checks if any item in a stream matches a predicate.
- Broadcast
Stream - Stream wrapper for broadcast receiver.
- Buffer
Unordered - A stream that buffers and polls futures, yielding results as they complete.
- Buffered
- A stream that buffers and polls futures, preserving order.
- Chain
- A stream that yields items from the first stream then the second.
- Chunks
- A stream that yields items in fixed-size chunks.
- Collect
- A future that collects all items from a stream into a collection.
- Count
- A future that counts the items in a stream.
- Debounce
- A stream that debounces items, emitting only after a quiet period.
- Enumerate
- Stream for the
enumeratemethod. - Filter
- A stream that yields only items matching a predicate.
- Filter
Map - A stream that yields only items matching an async predicate.
- Fold
- A future that folds all items from a stream into a single value.
- ForEach
- A future that executes a closure for each item in a stream.
- ForEach
Async - A future that executes an async closure for each item in a stream.
- Fuse
- Stream for the
fusemethod. - Inspect
- Stream for the
inspectmethod. - Iter
- A stream that yields items from an iterator.
- Map
- A stream that transforms each item using a function.
- Merge
- A stream that merges multiple streams.
- Next
- A future that returns the next item from a stream.
- Peekable
- A stream that supports peeking at the next element without consuming it.
- Ready
Chunks - A stream that yields chunks of immediately available items.
- Receiver
Stream - Stream wrapper for
mpsc::Receiver. - Scan
- A stream that yields intermediate accumulator values.
- Sink
Stream - Sink wrapper for mpsc sender.
- Skip
- Stream for the
skipmethod. - Skip
While - Stream for the
skip_whilemethod. - Take
- Stream for the
takemethod. - Take
While - Stream for the
take_whilemethod. - Then
- Stream for the
thenmethod. - Throttle
- A stream that yields at most one item per time period.
- TryCollect
- A future that collects items from a stream of Results.
- TryFold
- A future that folds items from a stream of Results.
- TryFor
Each - A future that executes a fallible closure for each item.
- Watch
Stream - Stream that yields when watch value changes.
- Zip
- A stream that zips two streams into pairs.
Enums§
- Broadcast
Stream Recv Error - Error from broadcast stream.
- TryStream
Error - Error returned by try-stream terminal combinators.
Traits§
- Stream
- Asynchronous iterator producing a sequence of values.
- Stream
Ext - Extension trait providing combinator methods for streams.