Skip to main content

Timer

Struct Timer 

Source
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>

Source

pub fn start(clock: C) -> Self

Start a timer using Clock::now as its initial reading.

Source

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.

Source

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.

Source

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.

Source

pub fn by_ref(&self) -> Timer<&C>

Get a new timer using the same initial reading, borrowing the Clock from this one.

Trait Implementations§

Source§

impl<C: Clone> Clone for Timer<C>

Source§

fn clone(&self) -> Timer<C>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<C: Copy> Copy for Timer<C>

Source§

impl<C: Clock> ToExtent for Timer<C>

Source§

fn to_extent(&self) -> Option<Extent>

Perform the conversion.

Auto Trait Implementations§

§

impl<C> Freeze for Timer<C>
where C: Freeze,

§

impl<C> RefUnwindSafe for Timer<C>
where C: RefUnwindSafe,

§

impl<C> Send for Timer<C>
where C: Send,

§

impl<C> Sync for Timer<C>
where C: Sync,

§

impl<C> Unpin for Timer<C>
where C: Unpin,

§

impl<C> UnsafeUnpin for Timer<C>
where C: UnsafeUnpin,

§

impl<C> UnwindSafe for Timer<C>
where C: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.