pub struct Timer<C> { /* private fields */ }Expand description
A timer that measures the point when an operation started and ended.
Implementations§
Source§impl<C: Clock> Timer<C>
impl<C: Clock> Timer<C>
Sourcepub fn start(clock: C) -> Self
pub fn start(clock: C) -> Self
Start a timer using Clock::now as its initial reading.
Sourcepub fn start_timestamp(&self) -> Option<Timestamp>
pub fn start_timestamp(&self) -> Option<Timestamp>
Get the timestamp taken when the timer was started.
If the underlying Clock was unable to produce an initial reading then this method will return None.
Sourcepub fn extent(&self) -> Option<Extent>
pub fn extent(&self) -> Option<Extent>
Get the value of the timer as an Extent, using Clock::now as its final reading.
If the underlying Clock is unable to produce a reading then this method will return None.
Sourcepub fn elapsed(&self) -> Option<Duration>
pub fn elapsed(&self) -> Option<Duration>
Get the timespan between the initial reading and Clock::now.
If the underlying Clock is unable to produce a reading, or it shifts to before the initial reading, then this method will return None.
This method is not guaranteed to return the actual time elapsed since the timer was started.
It’s based on the difference between two readings of the underlying Clock, which is not guaranteed to be monotonic.