[−][src]Struct sprocket_engine::Timer
A general purpose timer for measuring execution time or checking if a certain time has passed Timer can be stopped and this will stop time from being counted A timer can also have a target sets and can be queried if that target has been passed
Implementations
impl Timer
[src]
pub fn new() -> Self
[src]
Starts a new timer without a target
pub fn with_target(duration: Duration) -> Self
[src]
Creates a new timer which is going to be signaled after specified duration
pub fn set_target(&mut self, target: Option<Duration>)
[src]
Sets a target for timer Replaces an old one Does not reset a timer. Target can be immediately passed Signaled state reflects the new target
pub fn target(&self) -> Option<Duration>
[src]
Returns the current target for the timer
pub fn duration(&self) -> Duration
[src]
Returns the current duration of the timer If called on a stopped timer, it return that when it was stopped
pub fn stop(&mut self) -> Duration
[src]
Stops the timer and returns the duration The duration can be retrieved again with Timer::duration()
pub fn reset(&mut self)
[src]
Restarts a stopped timer Makes the timer be signaled again after target time from now
pub fn running(&self) -> bool
[src]
Returns true if the timer is currently running
pub fn stopped(&self) -> bool
[src]
Returns true if the timer is currently stopped The opposite of Timer::running()
pub fn signaled(&self) -> bool
[src]
Returns true if the timer has passed the target
pub fn remaining(&self) -> Option<Duration>
[src]
Returns the time to the target if any Returns None if target is None, target has passed, or timer is stopped
pub fn remaining_ms(&self) -> Option<usize>
[src]
Returns the time in whole milliseconds to the target if any Returns None if target is None, target has passed, or timer is stopped
pub fn remaining_us(&self) -> Option<usize>
[src]
Returns the time in whole microseconds to the target if any Returns None if target is None, target has passed, or timer is stopped
pub fn remaining_f32(&self) -> Option<f32>
[src]
Returns the time in fractional seconds to the target if any Returns None if target is None, target has passed, or timer is stopped
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]
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,
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, 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.
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>,