Struct cap_primitives::time::SystemTime
source · pub struct SystemTime { /* private fields */ }
Expand description
A measurement of the system clock, useful for talking to external entities like the file system or other processes.
This corresponds to std::time::SystemTime
.
This SystemTime
has no now
, elapsed
methods. To obtain the current
time or measure the duration to the current time, first obtain a
SystemClock
, and then call SystemClock::now
or
SystemClock::elapsed
instead. The UNIX_EPOCH
constant is at
SystemClock::UNIX_EPOCH
.
Similar to the filetime
crate, when
RUSTFLAGS=--cfg emulate_second_only_system
is set, SystemTime
will
round times from the operating system down to the second. This emulates
the behavior of some file systems, mostly
HFS, allowing debugging on other hardware.
Implementations§
source§impl SystemTime
impl SystemTime
sourcepub fn from_std(std: SystemTime) -> Self
pub fn from_std(std: SystemTime) -> Self
Constructs a new instance of Self
from the given
std::time::SystemTime
.
sourcepub const fn into_std(self) -> SystemTime
pub const fn into_std(self) -> SystemTime
Constructs a new instance of std::time::SystemTime
from the given
Self
.
sourcepub fn duration_since(&self, earlier: Self) -> Result<Duration, SystemTimeError>
pub fn duration_since(&self, earlier: Self) -> Result<Duration, SystemTimeError>
Returns the amount of time elapsed from another instant to this one.
This corresponds to std::time::SystemTime::duration_since
.
sourcepub fn checked_add(&self, duration: Duration) -> Option<Self>
pub fn checked_add(&self, duration: Duration) -> Option<Self>
Returns Some(t)
where t
is the time self + duration
if t
can be
represented as SystemTime
(which means it’s inside the bounds of the
underlying data structure), None
otherwise.
This corresponds to std::time::SystemTime::checked_add
.
sourcepub fn checked_sub(&self, duration: Duration) -> Option<Self>
pub fn checked_sub(&self, duration: Duration) -> Option<Self>
Returns Some(t)
where t
is the time self - duration
if t
can be
represented as SystemTime
(which means it’s inside the bounds of the
underlying data structure), None
otherwise.
This corresponds to std::time::SystemTime::checked_sub
.
Trait Implementations§
source§impl Add<Duration> for SystemTime
impl Add<Duration> for SystemTime
source§fn add(self, dur: Duration) -> Self
fn add(self, dur: Duration) -> Self
Panics
This function may panic if the resulting point in time cannot be
represented by the underlying data structure. See
SystemTime::checked_add
for a version without panic.
§type Output = SystemTime
type Output = SystemTime
+
operator.source§impl AddAssign<Duration> for SystemTime
impl AddAssign<Duration> for SystemTime
source§fn add_assign(&mut self, other: Duration)
fn add_assign(&mut self, other: Duration)
+=
operation. Read moresource§impl Clone for SystemTime
impl Clone for SystemTime
source§fn clone(&self) -> SystemTime
fn clone(&self) -> SystemTime
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for SystemTime
impl Debug for SystemTime
source§impl From<SystemTime> for SystemTimeSpec
impl From<SystemTime> for SystemTimeSpec
source§fn from(time: SystemTime) -> Self
fn from(time: SystemTime) -> Self
source§impl Hash for SystemTime
impl Hash for SystemTime
source§impl Ord for SystemTime
impl Ord for SystemTime
source§fn cmp(&self, other: &SystemTime) -> Ordering
fn cmp(&self, other: &SystemTime) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere Self: Sized,
source§impl PartialEq<SystemTime> for SystemTime
impl PartialEq<SystemTime> for SystemTime
source§fn eq(&self, other: &SystemTime) -> bool
fn eq(&self, other: &SystemTime) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd<SystemTime> for SystemTime
impl PartialOrd<SystemTime> for SystemTime
source§fn partial_cmp(&self, other: &SystemTime) -> Option<Ordering>
fn partial_cmp(&self, other: &SystemTime) -> 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 SystemTime
impl Sub<Duration> for SystemTime
source§impl SubAssign<Duration> for SystemTime
impl SubAssign<Duration> for SystemTime
source§fn sub_assign(&mut self, other: Duration)
fn sub_assign(&mut self, other: Duration)
-=
operation. Read more