Struct coarsetime::Instant
source · [−]pub struct Instant(_);
Expand description
A measurement of a monotonically increasing clock. Opaque and useful only with Duration
.
Implementations
sourceimpl 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
sourceimpl AddAssign<Duration> for Instant
impl AddAssign<Duration> for Instant
sourcefn add_assign(&mut self, rhs: Duration)
fn add_assign(&mut self, rhs: Duration)
Performs the +=
operation. Read more
sourceimpl Ord for Instant
impl Ord for Instant
sourceimpl PartialOrd<Instant> for Instant
impl PartialOrd<Instant> for Instant
sourcefn partial_cmp(&self, other: &Instant) -> Option<Ordering>
fn partial_cmp(&self, other: &Instant) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl SubAssign<Duration> for Instant
impl SubAssign<Duration> for Instant
sourcefn sub_assign(&mut self, rhs: Duration)
fn sub_assign(&mut self, rhs: Duration)
Performs the -=
operation. Read more
impl Copy for Instant
impl Eq for Instant
impl StructuralEq for Instant
impl StructuralPartialEq for Instant
Auto Trait Implementations
impl RefUnwindSafe for Instant
impl Send for Instant
impl Sync for Instant
impl Unpin for Instant
impl UnwindSafe for Instant
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more