[−][src]Struct ticktock::timer::Timer
Methods
impl<F, V, R> Timer<F, V, R> where
F: Fn(Duration, &mut V) -> R,
[src]
F: Fn(Duration, &mut V) -> R,
pub fn apply(func: F, initial: V) -> TimerBuilder<F, V, R>
[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.
pub fn interval(&self) -> Duration
[src]
Get timer interval
pub fn set_value(&mut self, value: V)
[src]
Replace the stored value
pub fn update(&mut self, now: Instant) -> Option<R>
[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]
F: Fn(Duration, &mut V) -> R,
Trait Implementations
impl<F, V, R> AsMut<V> for Timer<F, V, R> where
F: Fn(Duration, &mut V) -> R,
[src]
F: Fn(Duration, &mut V) -> R,
impl<F, V, R> AsRef<V> for Timer<F, V, R> where
F: Fn(Duration, &mut V) -> R,
[src]
F: Fn(Duration, &mut V) -> R,
impl<F: Debug, V: Debug, R: Debug> Debug for Timer<F, V, R> where
F: Fn(Duration, &mut V) -> R,
[src]
F: Fn(Duration, &mut V) -> R,
Auto Trait Implementations
impl<F, V, R> RefUnwindSafe for Timer<F, V, R> where
F: RefUnwindSafe,
V: RefUnwindSafe,
F: RefUnwindSafe,
V: RefUnwindSafe,
impl<F, V, R> Send for Timer<F, V, R> where
F: Send,
V: Send,
F: Send,
V: Send,
impl<F, V, R> Sync for Timer<F, V, R> where
F: Sync,
V: Sync,
F: Sync,
V: Sync,
impl<F, V, R> Unpin for Timer<F, V, R> where
F: Unpin,
V: Unpin,
F: Unpin,
V: Unpin,
impl<F, V, R> UnwindSafe for Timer<F, V, R> where
F: UnwindSafe,
V: UnwindSafe,
F: UnwindSafe,
V: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,