Struct omaha_client::time::ComplexTime
source · 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) and 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§fn eq(&self, other: &ComplexTime) -> bool
fn eq(&self, other: &ComplexTime) -> bool
self
and other
values to be equal, and is used
by ==
.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 more