Expand description
§Agent Rex
An async Stream-based FRP-like library for Rust.
This library provides composable stream operators similar to RxJS/Most.js,
built on top of the futures crate’s Stream trait.
§Runtime Agnostic
Most operators are runtime-agnostic and work with any async executor. For time-based operations, we provide generic versions that accept a sleep function parameter, plus feature-flagged implementations for specific runtimes (tokio, smol, async-std).
Modules§
- merge_
all - Merge multiple streams, interleaving values as they arrive.
Structs§
- Replay
Subject - A multicasting subject that replays buffered values to new subscribers. Uses only runtime-agnostic primitives from the futures crate.
- Retry
Options - Test
Interval - A stream that yields at regular intervals based on virtual time.
- Test
Runtime - A test runtime with virtual time for deterministic testing.
- Test
Sleep - A future that completes when the test runtime’s virtual time reaches the target.
- Throttle
Options - Unfold
Result
Traits§
- Runtime
- Runtime abstraction for async operations that need executor-specific features.
Functions§
- apply_
latest - Apply latest function to latest value.
- await_
tap - Await side effects before yielding values.
- buffer
- buffer_
time - Buffer values over time windows. Uses the Runtime trait for timer functionality.
- buffer_
time_ with - Runtime-agnostic buffer_time with custom sleep function
- chain
- concat
- Concatenates multiple streams into a single stream.
- concat2
- concat_
all - Flatten a stream of streams by concatenating them. Built-in: stream_of_streams.flatten()
- concat_
map - Map each value to a stream and concatenate results in order.
- constant
- Map to a constant value. stream.map(|_| constant_value.clone())
- continue_
with - Continue with another stream after the first completes.
- debounce
- Only emit a value if no new values arrive within the specified duration. Uses the Runtime trait for timer functionality.
- debounce_
with - Runtime-agnostic debounce that accepts a sleep function. Emits a value only after the specified duration has passed without new values.
- delay
- Delay each value by a specified duration. Uses the Runtime trait for timer functionality.
- delay_
test - Delay operator that works with TestRuntime.
- delay_
with - Runtime-agnostic delay that accepts a sleep function
- eager
- Pre-fetch values from a slow producer into a buffer. Uses the Runtime trait for spawning background consumption.
- eager_
now - Pre-fetch values immediately on creation using the Runtime trait.
- empty
- Creates a stream that immediately completes without emitting any values.
- filter
- Filters values in a stream based on a predicate.
- filter_
async - flat_
map - from_
bounded_ channel - Bounded variant for backpressure
- from_
channel - Creates a stream from a channel receiver. The sender can be used to push events from event handlers.
- from_
future - Creates a stream from a Future. When the Future resolves, the stream emits the value and completes.
- from_
iter - Creates a stream from an iterator.
- iterate
- Creates a stream that emits an infinite sequence by repeatedly applying a function.
- just
- Create a stream that emits a single value.
- latest2
- Combine two streams, emitting tuple of latest values. Runtime-agnostic using stream merging.
- map
- Maps each value in a stream using a function.
- merge
- Merge two streams, interleaving values as they arrive.
- merge_
all - Merge multiple streams, interleaving values as they arrive.
- never
- Creates a stream that never emits any values and never completes.
- of
- Alias for just
- periodic
- Creates a stream that emits () at regular intervals. Uses the Runtime trait abstraction for timer support.
- periodic_
test - Periodic stream using TestRuntime.
- periodic_
with_ timer - recover_
with - For streams that emit Result<T, E>, recover from errors.
- recover_
with_ stream - Recovers from errors by trying alternative streams from a provided iterator.
- replay_
factory_ spawned - Version that accepts a Runtime for spawning source consumption
- retry
- Retry a stream factory on error. Uses the Runtime trait for delay functionality.
- retry_
with - Runtime-agnostic retry with custom sleep function
- scan
- Scan with seed emission first (matching JS behavior).
- since_
stream - Emit from source only after start stream emits. Runtime-agnostic using futures::select!
- skip
- Skips the first
nvalues from a stream. - skip_
repeats - Filter consecutive duplicates using equality.
- skip_
repeats_ with - Filter consecutive duplicates using a custom equality function.
- skip_
while - Skips values from a stream while the predicate returns true.
- slice
- Emit values from index start to end (exclusive).
- start_
with - Prepends a value to the beginning of a stream.
- switch_
map - Switch to new inner stream on each outer value, cancelling previous. Runtime-agnostic using futures::select!
- take
- Takes the first
nvalues from a stream. - take_
until - Take values until predicate matches (matching value not emitted).
- take_
while - Takes values from a stream while the predicate returns true.
- tap
- Perform side effects for each value without modifying them. Runtime-agnostic - side effects are synchronous.
- tap_
spawn - For fire-and-forget async side effects using the Runtime trait.
- throttle
- Limit emission rate with leading/trailing edge control. This implementation is runtime-agnostic - it only uses std::time::Instant.
- throw_
error - Creates a stream that immediately emits an error.
- throw_
panic - unfold
- Creates a stream by unfolding a seed value.
- until_
stream - Emit from source until stop stream emits. Runtime-agnostic using futures::select!
- window
- Split source into windows of specified size. Each window is a vector of items (simpler than sub-streams).
Type Aliases§
- Boxed
Stream - Type alias for boxed streams