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
sourceimpl 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
sourceimpl Add<Duration> for SystemTime
impl Add<Duration> for SystemTime
sourceimpl AddAssign<Duration> for SystemTime
impl AddAssign<Duration> for SystemTime
sourcefn add_assign(&mut self, other: Duration)
fn add_assign(&mut self, other: Duration)
Performs the +=
operation. Read more
sourceimpl Clone for SystemTime
impl Clone for SystemTime
sourcefn clone(&self) -> SystemTime
fn clone(&self) -> SystemTime
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for SystemTime
impl Debug for SystemTime
sourceimpl From<SystemTime> for SystemTimeSpec
impl From<SystemTime> for SystemTimeSpec
sourcefn from(time: SystemTime) -> Self
fn from(time: SystemTime) -> Self
Performs the conversion.
sourceimpl Hash for SystemTime
impl Hash for SystemTime
sourceimpl Ord for SystemTime
impl Ord for SystemTime
sourceimpl PartialEq<SystemTime> for SystemTime
impl PartialEq<SystemTime> for SystemTime
sourcefn eq(&self, other: &SystemTime) -> bool
fn eq(&self, other: &SystemTime) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &SystemTime) -> bool
fn ne(&self, other: &SystemTime) -> bool
This method tests for !=
.
sourceimpl PartialOrd<SystemTime> for SystemTime
impl PartialOrd<SystemTime> for SystemTime
sourcefn partial_cmp(&self, other: &SystemTime) -> Option<Ordering>
fn partial_cmp(&self, other: &SystemTime) -> 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 Sub<Duration> for SystemTime
impl Sub<Duration> for SystemTime
sourceimpl SubAssign<Duration> for SystemTime
impl SubAssign<Duration> for SystemTime
sourcefn sub_assign(&mut self, other: Duration)
fn sub_assign(&mut self, other: Duration)
Performs the -=
operation. Read more
impl Copy for SystemTime
impl Eq for SystemTime
impl StructuralEq for SystemTime
impl StructuralPartialEq for SystemTime
Auto Trait Implementations
impl RefUnwindSafe for SystemTime
impl Send for SystemTime
impl Sync for SystemTime
impl Unpin for SystemTime
impl UnwindSafe for SystemTime
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