Struct sixtyfps_corelib::timers::Timer [−][src]
pub struct Timer { /* fields omitted */ }
Timer is a handle to the timer system that allows triggering a callback to be called after a specified period of time.
Implementations
impl Timer
[src]
impl Timer
[src]pub fn start(
&self,
mode: TimerMode,
duration: Duration,
callback: impl Fn() + 'static
)
[src]
&self,
mode: TimerMode,
duration: Duration,
callback: impl Fn() + 'static
)
Starts the timer with the given mode and duration, in order for the callback to called when the timer fires. If the timer has been started previously and not fired yet, then it will be restarted.
Arguments:
mode
: The timer mode to apply, i.e. whether to repeatedly fire the timer or just once.duration
: The duration from now until when the timer should fire.callback
: The function to call when the time has been reached or exceeded.
pub fn single_shot(duration: Duration, callback: impl FnOnce() + 'static)
[src]
Starts the timer with the duration, in order for the callback to called when the timer fires. It is fired only once and then deleted.
Arguments:
duration
: The duration from now until when the timer should fire.callback
: The function to call when the time has been reached or exceeded.
pub fn stop(&self)
[src]
Stops the previously started timer. Does nothing if the timer has never been started. A stopped timer cannot be restarted with restart() – instead you need to call start().
pub fn restart(&self)
[src]
Restarts the timer, if it was previously started.
pub fn running(&self) -> bool
[src]
Returns true if the timer is running; false otherwise.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Timer
impl !RefUnwindSafe for Timer
impl UnwindSafe for Timer
impl UnwindSafe for Timer