[][src]Struct wasm_stopwatch::Stopwatch

pub struct Stopwatch { /* fields omitted */ }

A stopwatch which tracks time in seconds, using performance.now().

Methods

impl Stopwatch[src]

pub fn new() -> Self[src]

Creates a new stopwatch with the current time set to 0.

pub fn with_speed(speed: f64) -> Self[src]

Creates a stopwatch which advances the given amount every second.

For instance, Stopwatch::with_speed(1.0/60.0) creates a stopwatch which uses minutes as the time unit instead of seconds.

pub fn paused(&self) -> bool[src]

Returns whether the stopwatch is paused.

pub fn pause(&mut self)[src]

Pauses the stopwatch. If the stopwatch was already paused, this does nothing.

pub fn unpause(&mut self)[src]

Unpauses the stopwatch. If the stopwatch was already unpaused, this does nothing.

pub fn toggle_pause(&mut self)[src]

Toggles whether the stopwatch is paused.

pub fn get_time(&self) -> f64[src]

Gets the current time.

pub fn set_time(&mut self, cur_time: f64)[src]

Sets the current time.

pub fn reset(&mut self)[src]

Resets the stopwatch to zero.

pub fn add_time(&mut self, time_diff: f64)[src]

Advances the stopwatch by time_diff.

Trait Implementations

impl Clone for Stopwatch[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

Auto Trait Implementations

impl Send for Stopwatch

impl Sync for Stopwatch

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

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

impl<T> From for T[src]

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

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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

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

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

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

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.