Advanced Streaming

Part V · Chapter 22 — windowing, joins, replay fanout, FSM scans, and transducers.

Part IV introduced the pull-based, chunked Stream<A, E = Never, R = HNil>. This chapter covers multi-stream patterns: grouping elements into windows, joining sources, replaying history to fanout branches, stepping simple state machines over elements, and applying composable transducers. Every operator pulls one upstream chunk per downstream pull, so memory stays bounded by the chunk size plus the operator's documented state.

Module map

All items are re-exported at the crate root (use id_effect::{Stream, combine_latest, …}).

SourceItems
window.rstumbling, sliding, session_by_gap, tumbling_by_time, sliding_by_time
join.rsStream::merge, combine_latest, keyed_join
zip.rsStream::zip, Stream::zip_with, Stream::combine_latest
time.rsStream::throttle, Stream::throttle_enforce, Stream::debounce
group.rsStream::group_by_key, Stream::group_by
broadcast.rsStream::broadcast, Stream::broadcast_replay, broadcast_with_replay
transduce.rsstate_scan, transduce_items / via_transducer
transducer.rsTransducer, transducer_map / transducer_filter / transducer_take

When to use what

  • Windows — aggregate or batch elements by count, time, or session gaps.
  • Joins — correlate two sources (merge for fair interleave, zip / zip_with for positional pairs, combine_latest for dashboards, keyed_join for per-key correlation).
  • Rate and grouping — throttle / debounce on the fiber clock (virtual time under TestExecutor), group_by_key / group_by to split a stream per key with bounded buffers.
  • Replay fanout — like broadcast, plus a retained tail replayed to each branch.
  • state_scan — emit only on FSM transitions (contrast with scan, which emits every step).
  • Transducers — reusable map/filter pipelines (the same type as id_effect_optics::Transducer).

See the section pages for examples; the tests in crates/id_effect/tests/stream*.rs exercise each operator.