pub trait Stopwatch {
    // Required methods
    fn from_millis(millis: u64) -> Self;
    fn as_secs(&self) -> u64;
    fn restart(&mut self);
    fn is_timeout(&self) -> bool;
    fn current_time_as_secs(&mut self) -> u64;

    // Provided method
    fn update(&mut self) { ... }
}
Expand description

Stopwatches are used when you need to know when time is up. This is when you need to assert a certain ammount of time has passed

Required Methods§

source

fn from_millis(millis: u64) -> Self

Creates a new instance with the target time as now + millis

source

fn as_secs(&self) -> u64

Returns the delta time in secs.

source

fn restart(&mut self)

Restarts the clock.

source

fn is_timeout(&self) -> bool

Returns true if the time set in Stopwatch::from_millis has passed

source

fn current_time_as_secs(&mut self) -> u64

Returns the current stopwatch time expressed as seconds.

Provided Methods§

source

fn update(&mut self)

This is used in case a manual update of the clock is required after each tick or cycle of the main event loop.

Object Safety§

This trait is not object safe.

Implementors§