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]

pub fn start(
    &self,
    mode: TimerMode,
    duration: Duration,
    callback: impl Fn() + 'static
)
[src]

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

impl Default for Timer[src]

impl Drop for Timer[src]

Auto Trait Implementations

impl !RefUnwindSafe for Timer

impl Send for Timer

impl !Sync for Timer

impl Unpin for Timer

impl UnwindSafe for Timer

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.