Struct ticktock::timer::Timer [] [src]

pub struct Timer<F, V, R> where
    F: Fn(Duration, &mut V) -> R, 
{ /* fields omitted */ }

Methods

impl<F, V, R> Timer<F, V, R> where
    F: Fn(Duration, &mut V) -> R, 
[src]

[src]

Construct new timer

The timer will periodically execute F, which will alter a value initially set to V.

F will be passed the elapsed time since the last execution as an argument. F may return a calculated result from updating.

[src]

Get timer interval

[src]

Replace the stored value

[src]

Execute function and calculate next execution instant

If now is less than the next execution instant, i.e. execution is not yet due, the function is not called, and None is returned.

Otherwise, the the next execution instant is calculated, the function called and the new value returned.

impl<F, V: Clone, R> Timer<F, V, R> where
    F: Fn(Duration, &mut V) -> R, 
[src]

[src]

Returns a copy of the value stored inside timer.

Trait Implementations

impl<F: Debug, V: Debug, R: Debug> Debug for Timer<F, V, R> where
    F: Fn(Duration, &mut V) -> R, 
[src]

[src]

Formats the value using the given formatter. Read more

impl<F, V, R> AsRef<V> for Timer<F, V, R> where
    F: Fn(Duration, &mut V) -> R, 
[src]

[src]

Performs the conversion.

impl<F, V, R> AsMut<V> for Timer<F, V, R> where
    F: Fn(Duration, &mut V) -> R, 
[src]

[src]

Performs the conversion.

Auto Trait Implementations

impl<F, V, R> Send for Timer<F, V, R> where
    F: Send,
    V: Send

impl<F, V, R> Sync for Timer<F, V, R> where
    F: Sync,
    V: Sync