pub struct Timer { /* private fields */ }Expand description
A timer that counts down and knows when a Duration has elapsed
Implementations§
Source§impl Timer
impl Timer
Sourcepub fn set<D: ToDuration>(time: D) -> Timer
pub fn set<D: ToDuration>(time: D) -> Timer
Creates a new Timer
Sourcepub fn duration_left(&self) -> Option<Duration>
pub fn duration_left(&self) -> Option<Duration>
Gets the time left as a Duration
Sourcepub fn seconds_left(&self) -> Seconds
pub fn seconds_left(&self) -> Seconds
Gets the time left as a floating-point number of seconds
Sourcepub fn as_ready(self) -> Option<Seconds>
pub fn as_ready(self) -> Option<Seconds>
Checks if the set Duration has elapsed and returns the elapsed
floating-point number of seconds if it has
Sourcepub fn max_duration(&self) -> Duration
pub fn max_duration(&self) -> Duration
Sourcepub fn max_seconds(&self) -> Seconds
pub fn max_seconds(&self) -> Seconds
Gets the time the Timer was originally set with as a floating-point number of seconds
Sourcepub fn started_at(&self) -> Instant
pub fn started_at(&self) -> Instant
Trait Implementations§
Source§impl Ord for Timer
impl Ord for Timer
Source§impl PartialOrd for Timer
impl PartialOrd for Timer
impl Copy for Timer
impl Eq for Timer
impl StructuralPartialEq for Timer
Auto Trait Implementations§
impl Freeze for Timer
impl RefUnwindSafe for Timer
impl Send for Timer
impl Sync for Timer
impl Unpin for Timer
impl UnwindSafe for Timer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more