rskit-pipeline — Async Stream Operators
RskitStreamExt adds lazy, backpressure-aware async operators to any futures::Stream.
Features
Operators available on any futures::Stream via RskitStreamExt:
rmap— async maprflatmap— async flat-maprfilter— predicate filterrtap— side-effect taprreduce— async fold/reducerparallel— concurrent execution with bounded parallelismrfan_out— broadcast to multiple async functionsrmerge— merge two streamsrpartition— split into matching and non-matching streamsrbatch— collect into fixed-size/time-limited batchesrdebounce— debounce with a quiet periodrthrottle— rate-limited throughputrtumbling_window— non-overlapping time windowsrsliding_window— overlapping item-count windowsrdistinct— first occurrence onlyrtake/rskip— bounded prefix operators
Operator reference
| Operator | rskit API | Semantics |
|---|---|---|
| map | RskitStreamExt::rmap |
Transform each item with a fallible async function. |
| filter | RskitStreamExt::rfilter |
Keep items matching a synchronous predicate. |
| batch | RskitStreamExt::rbatch |
Emit up to size items, or the partial batch when timeout elapses/upstream ends. |
| window | RskitStreamExt::rtumbling_window |
Emit non-overlapping windows bounded by duration and item count. |
| sliding | RskitStreamExt::rsliding_window |
Emit overlapping item-count windows advancing by step. |
| fan_out | RskitStreamExt::rfan_out |
Apply a bounded number of async functions to each item, poll branch futures concurrently in the stream task, and short-circuit on the first branch error. |
| parallel | RskitStreamExt::rparallel |
Process items concurrently with bounded parallelism; output order is not guaranteed. |
| merge | RskitStreamExt::rmerge, merge |
Yield items from whichever input stream is ready first. |
| partition | RskitStreamExt::rpartition |
Route each item to matching or remainder stream; one closed side does not close the other. |
| throttle | RskitStreamExt::rthrottle |
Emit at most one item per interval. |
| debounce | RskitStreamExt::rdebounce |
Wait for a quiet period, then emit the latest item. |
| distinct | RskitStreamExt::rdistinct |
Emit the first occurrence of each item. |
| take | RskitStreamExt::rtake |
Emit only the first n items. |
| skip | RskitStreamExt::rskip |
Drop the first n items. |
Sources
| Source | rskit API | Semantics |
|---|---|---|
| from_slice | from_slice |
Stream a Vec<T> in order. |
| from_fn | from_fn |
Lazily generate items from an async closure until it returns None. |
| from_channel | from_channel |
Wrap a tokio::sync::mpsc::Receiver as a stream. |
| broadcaster | Broadcaster<T> |
Bounded, cancellable one-to-many fan-out: each subscribe returns its own bounded BroadcastStream; lagging subscribers drop overflow (never block the broadcaster), disconnected ones are pruned lazily. Cancellation via CancellationToken. |
Broadcaster<T> is the canonical owner for "observe a backend → bounded, cancellable stream of typed change events" — config reloads, service discovery, cache invalidation, secret rotation — instead of each crate reinventing a per-subscriber fan-out.
Usage
[]
= "0.1.0-alpha.1"
= "0.1.0-alpha.1"
use StreamExt;
use ;
let results = from_slice
.rfilter
.rmap
.
.await;
// [Ok(20), Ok(40)]