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.
source§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 for SystemTime
impl PartialEq for SystemTime
source§impl PartialOrd for SystemTime
impl PartialOrd for SystemTime
source§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 moreimpl Copy for SystemTime
impl Eq for SystemTime
impl StructuralPartialEq for SystemTime
Auto Trait Implementations§
impl Freeze for SystemTime
impl RefUnwindSafe for SystemTime
impl Send for SystemTime
impl Sync for SystemTime
impl Unpin for SystemTime
impl UnwindSafe for SystemTime
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: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)