Trait ReactionTrigger

Source
pub trait ReactionTrigger<T> {
    // Required methods
    fn get_value(&self, now: &EventTag, start: &Instant) -> Option<T>
       where T: Copy;
    fn use_value_ref<O>(
        &self,
        now: &EventTag,
        start: &Instant,
        action: impl FnOnce(Option<&T>) -> O,
    ) -> O;

    // Provided method
    fn is_present(&self, now: &EventTag, start: &Instant) -> bool { ... }
}
Expand description

Common trait for actions, ports, and timer objects handed to reaction functions. This is meant to be used through the API of ReactionCtx instead of directly.

Required Methods§

Source

fn get_value(&self, now: &EventTag, start: &Instant) -> Option<T>
where T: Copy,

Copies the value out, if it is present. Whether a value is present is not in general the same thing as whether this trigger Self::is_present. See crate::ReactionCtx::get.

Source

fn use_value_ref<O>( &self, now: &EventTag, start: &Instant, action: impl FnOnce(Option<&T>) -> O, ) -> O

Execute an action using the current value of this trigger. The closure is called even if the value is absent (with a None argument).

Provided Methods§

Source

fn is_present(&self, now: &EventTag, start: &Instant) -> bool

Returns whether the trigger is present, given that the current logical time is the parameter.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§