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: InstantImplementations§
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
AddAssign implementation that relies on the above Add implementation.
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 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for ComplexTime
Source§impl Debug for ComplexTime
impl Debug for ComplexTime
Source§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.
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 }"
);impl Eq for ComplexTime
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 SystemTime
impl From<ComplexTime> for SystemTime
Source§fn from(complex: ComplexTime) -> SystemTime
fn from(complex: ComplexTime) -> SystemTime
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 PartialComplexTime
impl From<ComplexTime> for PartialComplexTime
Source§fn from(t: ComplexTime) -> Self
fn from(t: ComplexTime) -> Self
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 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 ==.impl StructuralPartialEq for ComplexTime
Source§impl Sub<Duration> for ComplexTime
A Sub implementation for ComplexTime that subtracts the duration from both times that
the ComplexTime holds.
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
AddAssign implementation that relies on the above Add implementation.
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 moreAuto Trait Implementations§
impl Freeze for ComplexTime
impl RefUnwindSafe for ComplexTime
impl Send for ComplexTime
impl Sync for ComplexTime
impl Unpin for ComplexTime
impl UnsafeUnpin 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,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.impl<T, Rhs, Output> GroupOps<Rhs, Output> for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute] value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi [Quirk] value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);