Struct Timer

Source
pub struct Timer {
    pub offset: Duration,
    pub period: Duration,
    /* private fields */
}
Expand description

A timer is conceptually a logical action that may re-schedule itself periodically.

For periodic timers, a reaction is synthesized which reschedules the timer.

Fields§

§offset: Duration

Minimal duration after the start of the program after which the timer starts to trigger.

§period: Duration

Period between events emitted by this timer. A period of zero means that the timer will trigger exactly once after the specified offset.

Implementations§

Source§

impl Timer

Source

pub fn is_periodic(&self) -> bool

Whether the timer should repeat itself. A period of zero means that the timer will trigger exactly once after the specified offset.

Trait Implementations§

Source§

impl ReactionTrigger<()> for Timer

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

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

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<&()>) -> 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).

Auto Trait Implementations§

§

impl Freeze for Timer

§

impl RefUnwindSafe for Timer

§

impl Send for Timer

§

impl Sync for Timer

§

impl Unpin for Timer

§

impl UnwindSafe for Timer

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.