Struct coarsetime::Instant
source · pub struct Instant(/* private fields */);
Expand description
A measurement of a monotonically increasing clock. Opaque and useful only
with Duration
.
Resulting durations are actual durations; they do not get affected by
clock adjustments, leap seconds, or similar.
In order to get a measurement of the wall clock, use Date
instead.
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 now_without_cache_update() -> Instant
pub fn now_without_cache_update() -> Instant
Returns an instant corresponding to “now” without updating the cached value.
After this, recent()
will still return the old instant.
now()
is generally preferred over this function.
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 for Instant
impl PartialEq for Instant
source§impl PartialOrd for Instant
impl PartialOrd 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 moreimpl Copy for Instant
impl Eq for Instant
impl StructuralPartialEq for Instant
Auto Trait Implementations§
impl Freeze for Instant
impl RefUnwindSafe for Instant
impl Send for Instant
impl Sync for Instant
impl Unpin for Instant
impl UnwindSafe for Instant
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
source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)