Struct clocksource::coarse::UnixInstant
source · pub struct UnixInstant { /* private fields */ }
Expand description
A measurement of the system clock in seconds.
An precise::UnixInstant
represents a moment in time and is taken from the
system realtime clock. Unlike std::time::SystemTime
the internal
representation uses only seconds in a u32 field to hold the clock reading.
This will wrap on Feb 07 2106 (UTC) and cannot represent times before the UNIX epoch on Jan 01 1970 (UTC).
As with std::time::SystemTime
, UnixInstant
s are not guaranteed to be
steady. They are taken from a clock which is subject to phase and frequency
adjustments. This means that they may jump forward or backwards and speed up
or slow down.
This type is useful for representing moments in time across restarts and across systems as long as the clocks are reasonably synchronized to a common reference.
The size of a coarse::UnixInstant
is always the same as a u32
.
Implementations§
source§impl UnixInstant
impl UnixInstant
pub const EPOCH: UnixInstant = _
sourcepub fn elapsed(&self) -> Duration
pub fn elapsed(&self) -> Duration
Return the elapsed time, in nanoseconds, since the original timestamp.
sourcepub fn duration_since(&self, earlier: Self) -> Duration
pub fn duration_since(&self, earlier: Self) -> Duration
Return the elapsed duration, in nanoseconds, from some earlier timestamp until this timestamp.
pub fn checked_duration_since(&self, earlier: Self) -> Option<Duration>
pub fn checked_sub(&self, duration: Duration) -> Option<Self>
Trait Implementations§
source§impl Add<Duration> for UnixInstant
impl Add<Duration> for UnixInstant
source§impl Add<Duration> for UnixInstant
impl Add<Duration> for UnixInstant
source§impl AddAssign<Duration> for UnixInstant
impl AddAssign<Duration> for UnixInstant
source§fn add_assign(&mut self, rhs: Duration)
fn add_assign(&mut self, rhs: Duration)
+=
operation. Read moresource§impl AddAssign<Duration> for UnixInstant
impl AddAssign<Duration> for UnixInstant
source§fn add_assign(&mut self, rhs: Duration)
fn add_assign(&mut self, rhs: Duration)
+=
operation. Read moresource§impl Clone for UnixInstant
impl Clone for UnixInstant
source§fn clone(&self) -> UnixInstant
fn clone(&self) -> UnixInstant
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for UnixInstant
impl Debug for UnixInstant
source§impl Default for UnixInstant
impl Default for UnixInstant
source§fn default() -> UnixInstant
fn default() -> UnixInstant
source§impl From<UnixInstant> for AtomicUnixInstant
impl From<UnixInstant> for AtomicUnixInstant
source§fn from(other: UnixInstant) -> Self
fn from(other: UnixInstant) -> Self
source§impl From<UnixInstant> for AtomicUnixInstant
impl From<UnixInstant> for AtomicUnixInstant
source§fn from(other: UnixInstant) -> Self
fn from(other: UnixInstant) -> Self
source§impl From<UnixInstant> for DateTime
impl From<UnixInstant> for DateTime
source§fn from(other: UnixInstant) -> Self
fn from(other: UnixInstant) -> Self
source§impl From<UnixInstant> for UnixInstant
impl From<UnixInstant> for UnixInstant
source§fn from(other: UnixInstant) -> Self
fn from(other: UnixInstant) -> Self
source§impl Hash for UnixInstant
impl Hash for UnixInstant
source§impl Ord for UnixInstant
impl Ord for UnixInstant
source§fn cmp(&self, other: &UnixInstant) -> Ordering
fn cmp(&self, other: &UnixInstant) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq for UnixInstant
impl PartialEq for UnixInstant
source§fn eq(&self, other: &UnixInstant) -> bool
fn eq(&self, other: &UnixInstant) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for UnixInstant
impl PartialOrd for UnixInstant
source§fn partial_cmp(&self, other: &UnixInstant) -> Option<Ordering>
fn partial_cmp(&self, other: &UnixInstant) -> Option<Ordering>
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 Sub<Duration> for UnixInstant
impl Sub<Duration> for UnixInstant
source§impl Sub<Duration> for UnixInstant
impl Sub<Duration> for UnixInstant
source§impl Sub for UnixInstant
impl Sub for UnixInstant
source§impl SubAssign<Duration> for UnixInstant
impl SubAssign<Duration> for UnixInstant
source§fn sub_assign(&mut self, rhs: Duration)
fn sub_assign(&mut self, rhs: Duration)
-=
operation. Read moresource§impl SubAssign<Duration> for UnixInstant
impl SubAssign<Duration> for UnixInstant
source§fn sub_assign(&mut self, rhs: Duration)
fn sub_assign(&mut self, rhs: Duration)
-=
operation. Read more