Skip to main content

Crate agent_rex

Crate agent_rex 

Source
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§

ReplaySubject
A multicasting subject that replays buffered values to new subscribers. Uses only runtime-agnostic primitives from the futures crate.
RetryOptions
TestInterval
A stream that yields at regular intervals based on virtual time.
TestRuntime
A test runtime with virtual time for deterministic testing.
TestSleep
A future that completes when the test runtime’s virtual time reaches the target.
ThrottleOptions
UnfoldResult

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 n values 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 n values 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§

BoxedStream
Type alias for boxed streams