pub struct ComplexTime {
pub wall: SystemTime,
pub mono: Instant,
}
Expand description
This is a complete ComplexTime
, which has values on both the wall clock timeline and the
monotonic clock timeline.
It is not necessarily intended that both values refer to the same moment. They can, or they
can refer to a time on each clock’s respective timeline, e.g. for use with the Timer
trait.
The ComplexTime
type implements all the standard math operations in std::ops
that are
implemented for both std::time::SystemTime
and std::time::Instant
. Like those
implementations, it will panic on overflow.
Fields§
§wall: SystemTime
§mono: Instant
Implementations§
Source§impl ComplexTime
impl ComplexTime
Sourcepub fn truncate_submicrosecond_walltime(&self) -> ComplexTime
pub fn truncate_submicrosecond_walltime(&self) -> ComplexTime
Truncate the submicrosecond part of the walltime.
Sourcepub fn wall_duration_since(
&self,
earlier: impl Into<SystemTime>,
) -> Result<Duration, SystemTimeError>
pub fn wall_duration_since( &self, earlier: impl Into<SystemTime>, ) -> Result<Duration, SystemTimeError>
Compute the Duration since the given SystemTime, for the SystemTime component of this
ComplexTime. If this ComplexTime’s SystemTime is before the given time, the Duration
is returned as Err (same as SystemTime::duration_since()
)
Sourcepub fn is_after_or_eq_any(&self, other: impl Into<PartialComplexTime>) -> bool
pub fn is_after_or_eq_any(&self, other: impl Into<PartialComplexTime>) -> bool
Returns true
if this ComplexTime is after either the SystemTime or the Instant of the
given PartialComplexTime.
Trait Implementations§
Source§impl Add<Duration> for ComplexTime
impl Add<Duration> for ComplexTime
Source§impl AddAssign<Duration> for ComplexTime
impl AddAssign<Duration> for ComplexTime
AddAssign implementation that relies on the above Add implementation.
Source§fn add_assign(&mut self, other: Duration)
fn add_assign(&mut self, other: Duration)
+=
operation. Read moreSource§impl Clone for ComplexTime
impl Clone for ComplexTime
Source§fn clone(&self) -> ComplexTime
fn clone(&self) -> ComplexTime
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for ComplexTime
impl Debug for ComplexTime
Source§impl Display for ComplexTime
impl Display for ComplexTime
ComplexTime
implements Display
to provide a human-readable, detailed, format for its
values. It uses the ReadableSystemTime
struct for its SystemTime
component, and the
Debug
trait implementation of Instant
, as that type’s internals are not accessible, and
it only implements Debug
.
§Example
use omaha_client::time::ComplexTime;
use std::time::{Duration, Instant, SystemTime};
assert_eq!(
format!("{}", ComplexTime{
wall: SystemTime::UNIX_EPOCH + Duration::from_nanos(994610096026420000),
mono: Instant::now(),
}),
"2001-07-08 16:34:56.026 UTC (994610096.026420000) at Instant{ tv_sec: SEC, tv_nsec: NSEC }"
);
Source§impl From<(SystemTime, Instant)> for ComplexTime
impl From<(SystemTime, Instant)> for ComplexTime
Source§fn from(t: (SystemTime, Instant)) -> ComplexTime
fn from(t: (SystemTime, Instant)) -> ComplexTime
Source§impl From<ComplexTime> for Instant
impl From<ComplexTime> for Instant
Source§fn from(complex: ComplexTime) -> Instant
fn from(complex: ComplexTime) -> Instant
Source§impl From<ComplexTime> for Option<PartialComplexTime>
impl From<ComplexTime> for Option<PartialComplexTime>
Source§fn from(t: ComplexTime) -> Self
fn from(t: ComplexTime) -> Self
Source§impl From<ComplexTime> for PartialComplexTime
impl From<ComplexTime> for PartialComplexTime
Source§fn from(t: ComplexTime) -> Self
fn from(t: ComplexTime) -> Self
Source§impl From<ComplexTime> for SystemTime
impl From<ComplexTime> for SystemTime
Source§fn from(complex: ComplexTime) -> SystemTime
fn from(complex: ComplexTime) -> SystemTime
Source§impl Hash for ComplexTime
impl Hash for ComplexTime
Source§impl PartialEq for ComplexTime
impl PartialEq for ComplexTime
Source§impl Sub<Duration> for ComplexTime
impl Sub<Duration> for ComplexTime
A Sub
implementation for ComplexTime that subtracts the duration from both times that
the ComplexTime holds.
Source§impl SubAssign<Duration> for ComplexTime
impl SubAssign<Duration> for ComplexTime
AddAssign implementation that relies on the above Add implementation.
Source§fn sub_assign(&mut self, other: Duration)
fn sub_assign(&mut self, other: Duration)
-=
operation. Read moreimpl Copy for ComplexTime
impl Eq for ComplexTime
impl StructuralPartialEq for ComplexTime
Auto Trait Implementations§
impl Freeze for ComplexTime
impl RefUnwindSafe for ComplexTime
impl Send for ComplexTime
impl Sync for ComplexTime
impl Unpin for ComplexTime
impl UnwindSafe for ComplexTime
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
)