pub struct Periodic<B: Behavior> { /* private fields */ }Expand description
Infallible fold invoked for each accepted periodic generation.
fn fallible(_: &mut App) -> behavior::BehaviorActed<App> { Ok(behavior::Actions::cont()) }
let _ = behavior_actors::Periodic::new(App, behavior_actors::TimerId(1), std::time::Duration::from_secs(1), fallible);Repeatedly notify a wrapped behavior at a relative interval.
Initialization preserves inner effects and appends generation zero. Each
matching timer event is consumed once, folds on_elapsed, and—only when
that fold continues—appends the next generation. Stale, duplicate, and
wrong-ID observations are inert unless the inner protocol accepts them.
Termination emits no replacement. Generation exhaustion leaves the
timer retired while preserving the inner continuation. These are Bombay
policies; clock access and sleeping remain bombay-timers capabilities.
Reactions are infallible because they receive mutable access to the wrapped
behavior; ordinary delegated transitions retain the wrapped error type.
Implementations§
Source§impl<B: Behavior> Periodic<B>
impl<B: Behavior> Periodic<B>
Sourcepub fn new(
inner: B,
id: TimerId,
every: Duration,
on_elapsed: TimedReaction<B>,
) -> Self
pub fn new( inner: B, id: TimerId, every: Duration, on_elapsed: TimedReaction<B>, ) -> Self
Wrap inner with a relative periodic timer and pure reaction.
Accepted timer generations are rearmed only after a continuing reaction. Clock access and scheduling remain interpreter capabilities.