Expand description
Temporal operators — time-dependent transforms on reactive streams.
§Operators
sample— pure reactive; emits source’s latest value when notifier fires. No timer needed.debounce— emits aftermsof quiet (no new upstream DATA).throttle— rate-limits: at most one emission permswindow. Configurable leading / trailing edge.delay— delays each upstream DATA byms. Multiple in-flight.audit— on first DATA, starts amstimer; when it fires, emits the latest value. Timer does NOT restart on subsequent DATA within the window.interval— source that emits a monotonic counter everyperiod_ms.timeout— errors if no DATA arrives withinmsafter subscribe or after the previous DATA.buffer_time— collects upstream DATA into a buffer and flushes as a packed tuple everymsmilliseconds.window_time— rotates inner sub-nodes everymsmilliseconds; upstream DATA is forwarded to the current window node.
§Architecture
Timer operators (debounce, throttle, delay, audit) spawn a per-operator
tokio task that owns all pending state (handles, counters) exclusively.
The sync sink callback sends [TemporalCmd] commands; the async task
manages timers via tokio::time and calls Core::emit_or_defer /
complete_or_defer / error_or_defer when ready. This avoids the
double-ownership problem that would arise from tracking pending handles
in both the operator’s state mutex and the generic timer substrate.
sample is a pure-reactive producer-pattern node with two subscriptions
(source + notifier) and no timer dependency.
All temporal operators require a tokio runtime context at activation
time (first subscriber triggers the build closure, which calls
tokio::spawn).
Structs§
- Throttle
Opts - Options for
throttle.
Functions§
- audit
- On the first upstream DATA in each window, starts a
mstimer. When the timer fires, emits the latest value received during the window. Subsequent DATA values within the window update the stored value but do NOT restart the timer. - buffer_
time - Collects upstream DATA handles into a buffer and flushes them as a
packed tuple every
msmilliseconds. - debounce
- Emits after
delayof quiet — each new upstream DATA resets the timer. - delay
- Delays each upstream DATA by
msmilliseconds. Multiple values can be in-flight simultaneously, each with its own timer. - interval
- Source that emits a monotonically increasing counter (
1, 2, 3, …) everyperiod_msmilliseconds. Counter starts at 1 (not 0) becauseHandleId(0)is theNO_HANDLEsentinel. Resubscribable: counter resets on deactivation + reactivation. - sample
- Emits the source’s latest DATA each time
notifierdelivers DATA. - throttle
- Rate-limits upstream emissions to at most one per
ms-millisecond window. - timeout
- Errors if no upstream DATA arrives within
msmilliseconds after subscribe or after the previous DATA. Each DATA resets the timer. - window_
time - Rotates sub-node windows every
msmilliseconds.