Struct coarsetime::Instant
source · pub struct Instant(_);
Expand description
A measurement of a monotonically increasing clock. Opaque and useful only with Duration
.
Implementations§
source§impl Instant
impl Instant
sourcepub fn now() -> Instant
pub fn now() -> Instant
Returns an instant corresponding to “now”
This function also updates the stored instant.
sourcepub fn update()
pub fn update()
Update the stored instant
This function should be called frequently, for example in an event loop or using an
Updater
task.
sourcepub fn duration_since(&self, earlier: Instant) -> Duration
pub fn duration_since(&self, earlier: Instant) -> Duration
Returns the amount of time elapsed from another instant to this one
sourcepub fn elapsed_since_recent(&self) -> Duration
pub fn elapsed_since_recent(&self) -> Duration
Returns the amount of time elapsed between the this instant was created and the latest update
sourcepub fn elapsed(&self) -> Duration
pub fn elapsed(&self) -> Duration
Returns the amount of time elapsed since this instant was created
This function also updates the stored instant.
sourcepub fn as_ticks(&self) -> u64
pub fn as_ticks(&self) -> u64
Return a representation of this instant as a number of “ticks”.
Note that length of a ‘tick’ is not guaranteed to represent
the same amount of time across different platforms, or from
one version of coarsetime
to another.
Note also that the instant represented by “0” ticks is
unspecified. It is not guaranteed to be the same time across
different platforms, or from one version of coarsetime
to
another.
This API is mainly intended for applications that need to
store the value of an Instant
in an
AtomicU64
.
Trait Implementations§
source§impl AddAssign<Duration> for Instant
impl AddAssign<Duration> for Instant
source§fn add_assign(&mut self, rhs: Duration)
fn add_assign(&mut self, rhs: Duration)
+=
operation. Read moresource§impl Ord for Instant
impl Ord for Instant
source§impl PartialEq<Instant> for Instant
impl PartialEq<Instant> for Instant
source§impl PartialOrd<Instant> for Instant
impl PartialOrd<Instant> for Instant
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl SubAssign<Duration> for Instant
impl SubAssign<Duration> for Instant
source§fn sub_assign(&mut self, rhs: Duration)
fn sub_assign(&mut self, rhs: Duration)
-=
operation. Read more