pub struct MockInstant { /* private fields */ }Expand description
A monotonic instant measured from a crate::MockTimeline origin.
MockInstant is the deadline value used by crate::MockTimeline. It is
intentionally monotonic and relative: it stores nanoseconds since a timeline
origin, not a UTC timestamp. It also carries the id of the timeline that
produced it through crate::MockTimeline::now.
Instants can be ordered and can be advanced with
saturating_add, which is useful for computing
relative deadlines. Ordering is defined only for instants from the same
timeline. Passing an instant from one timeline to another timeline’s wait
API is rejected with crate::MockTimeError::MismatchedTimeline.
Implementations§
Source§impl MockInstant
impl MockInstant
Sourcepub const fn timeline_id(&self) -> u64
pub const fn timeline_id(&self) -> u64
Sourcepub const fn nanos_since_origin(&self) -> u128
pub const fn nanos_since_origin(&self) -> u128
Returns the instant offset from the timeline origin in nanoseconds.
§Returns
Nanoseconds since the mock timeline origin.
Sourcepub fn saturating_add(self, duration: Duration) -> Self
pub fn saturating_add(self, duration: Duration) -> Self
Trait Implementations§
Source§impl Clone for MockInstant
impl Clone for MockInstant
Source§fn clone(&self) -> MockInstant
fn clone(&self) -> MockInstant
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MockInstant
impl Debug for MockInstant
Source§impl Hash for MockInstant
impl Hash for MockInstant
Source§impl PartialEq for MockInstant
impl PartialEq for MockInstant
Source§fn eq(&self, other: &MockInstant) -> bool
fn eq(&self, other: &MockInstant) -> bool
self and other values to be equal, and is used by ==.Source§impl PartialOrd for MockInstant
impl PartialOrd for MockInstant
Source§fn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
Compares two instants only when they belong to the same timeline.
§Returns
Some(ordering) for instants from the same timeline, or None for
instants from different timelines.