pub struct LogicalTime(/* private fields */);Expand description
Represents an absolute point in time in nanoseconds.
Parts of this API are largely inspired by std::time::Duration.
This could go to 128 bits if we need more than ~585 years of nanosecond precision.
Implementations§
Source§impl LogicalTime
impl LogicalTime
Sourcepub const ZERO: LogicalTime
pub const ZERO: LogicalTime
0 integer nanoseconds.
Sourcepub const MAX: LogicalTime
pub const MAX: LogicalTime
The maximum representable integer nanoseconds.
Sourcepub const INDEFINITE: LogicalTime = LogicalTime::MAX
pub const INDEFINITE: LogicalTime = LogicalTime::MAX
The sentinel deadline for a wait that has no deadline.
A pause(2) blocks until a signal arrives and can never time out, so it
registers this value rather than a real deadline. The saturating Add
impls below also land here when a guest arms an absurdly far-future timer
(issue #219), which is the same situation: a deadline that can never be
reached while virtual time remains representable.
Callers that fast-forward virtual time to a pending deadline must check
LogicalTime::is_indefinite first. Jumping the global clock onto this
value would both destroy the continuity of virtual time (a ~584-year
step) and wake a waiter that Linux would have left blocked.
Sourcepub fn is_indefinite(&self) -> bool
pub fn is_indefinite(&self) -> bool
Is this the LogicalTime::INDEFINITE sentinel, i.e. “no deadline”?
Sourcepub fn as_micros(&self) -> u64
pub fn as_micros(&self) -> u64
Returns the total number of whole microseconds contained by this LogicalTime.
Sourcepub fn as_millis(&self) -> u64
pub fn as_millis(&self) -> u64
Returns the total number of whole milliseconds contained by this LogicalTime.
Sourcepub fn as_nanos(&self) -> u64
pub fn as_nanos(&self) -> u64
Returns the total number of nanoseconds contained by this LogicalTime.
Sourcepub fn as_secs(&self) -> u64
pub fn as_secs(&self) -> u64
Returns the total number of whole seconds contained by this LogicalTime.
The returned value does not include fractional (nanosecond) part of the duration,
which can be obtained using subsec_nanos.
Sourcepub fn from_micros(micros: u64) -> Self
pub fn from_micros(micros: u64) -> Self
Creates a new LogicalTime from the specified number of microseconds.
Sourcepub fn from_millis(millis: u64) -> Self
pub fn from_millis(millis: u64) -> Self
Creates a new LogicalTime from the specified number of milliseconds.
Sourcepub fn from_nanos(nanos: u64) -> Self
pub fn from_nanos(nanos: u64) -> Self
Creates a new LogicalTime from the specified number of nanoseconds.
Sourcepub fn from_big_nanos(nanos: u128) -> Self
pub fn from_big_nanos(nanos: u128) -> Self
Creates a new LogicalTime from the specified number of nanoseconds.
Sourcepub fn from_secs(secs: u64) -> Self
pub fn from_secs(secs: u64) -> Self
Creates a new LogicalTime from the specified number of seconds.
Sourcepub fn subsec_micros(&self) -> u32
pub fn subsec_micros(&self) -> u32
Returns the fractional part of this LogicalTime, in microseconds.
This method does not return the length of the duration when represented by microseconds. The returned number always represents
a fractional portion of a second (i.e., it is less than one million).
Sourcepub fn subsec_millis(&self) -> u32
pub fn subsec_millis(&self) -> u32
Returns the fractional part of this LogicalTime, in milliseconds.
This method does not return the length of the duration when represented by milliseconds. The returned number always represents
a fractional portion of a second (i.e., it is less than one thousand).
Sourcepub fn subsec_nanos(&self) -> u32
pub fn subsec_nanos(&self) -> u32
Returns the fractional part of this LogicalTime, in nanoseconds.
This method does not return the length of the duration when represented by nanoseconds. The returned number always represents
a fractional portion of a second (i.e., it is less than one billion).
Sourcepub fn from_rcbs(n: u64) -> Self
pub fn from_rcbs(n: u64) -> Self
Convert a number of Retired Conditional Branches (RCBs) to Nanoseconds
Sourcepub fn into_rcbs(self) -> u64
pub fn into_rcbs(self) -> u64
Inverse of from_rcbs. Non-injective, as it loses information, truncating to a coarser grained unit of time.
Sourcepub fn into_rcbs_with_multiplier(self, multiplier: f64) -> u64
pub fn into_rcbs_with_multiplier(self, multiplier: f64) -> u64
Convert a virtual duration to RCBs after applying a logical clock multiplier.
Sourcepub fn duration_since(&self, from: LogicalTime) -> Duration
pub fn duration_since(&self, from: LogicalTime) -> Duration
Measure the duration of the time interval since a previous time.
Trait Implementations§
Source§impl Add for LogicalTime
impl Add for LogicalTime
Source§impl Add<Duration> for LogicalTime
impl Add<Duration> for LogicalTime
Source§impl Add<u128> for LogicalTime
impl Add<u128> for LogicalTime
Source§impl Clone for LogicalTime
impl Clone for LogicalTime
impl Copy for LogicalTime
Source§impl Debug for LogicalTime
impl Debug for LogicalTime
Source§impl Default for LogicalTime
impl Default for LogicalTime
Source§impl<'de> Deserialize<'de> for LogicalTime
impl<'de> Deserialize<'de> for LogicalTime
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for LogicalTime
impl Display for LogicalTime
impl Eq for LogicalTime
Source§impl From<LogicalTime> for Timespec
impl From<LogicalTime> for Timespec
Source§fn from(logical_time: LogicalTime) -> Timespec
fn from(logical_time: LogicalTime) -> Timespec
Source§impl From<LogicalTime> for Timeval
impl From<LogicalTime> for Timeval
Source§fn from(logical_time: LogicalTime) -> Timeval
fn from(logical_time: LogicalTime) -> Timeval
Source§impl Hash for LogicalTime
impl Hash for LogicalTime
Source§impl Ord for LogicalTime
impl Ord for LogicalTime
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for LogicalTime
impl PartialEq for LogicalTime
Source§impl PartialOrd for LogicalTime
impl PartialOrd for LogicalTime
Source§impl Serialize for LogicalTime
impl Serialize for LogicalTime
impl StructuralPartialEq for LogicalTime
Auto Trait Implementations§
impl Freeze for LogicalTime
impl RefUnwindSafe for LogicalTime
impl Send for LogicalTime
impl Sync for LogicalTime
impl Unpin for LogicalTime
impl UnsafeUnpin for LogicalTime
impl UnwindSafe for LogicalTime
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§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.