[−][src]Struct wasm_stopwatch::Stopwatch
Implementations
impl Stopwatch
[src]
A stopwatch which tracks time in seconds.
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
.
pub fn sleep_until(&self, time: f64)
[src]
Sleeps until this stopwatch reaches the given time. May sleep for slightly longer than
requested (the same behavior as std::thread::sleep
), so in practice most games should
use vsync or similar mechanisms instead of using this to maintain a certain frame rate.
Panics if the stopwatch is paused.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Stopwatch
impl Send for Stopwatch
impl Sync for Stopwatch
impl Unpin for Stopwatch
impl UnwindSafe for Stopwatch
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,
pub 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> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
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.
pub 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>,