pub struct Instant(/* private fields */);Expand description
A monotonic reading from an injected clock.
§Why a duration and not a wall clock
Two sessions started in the same millisecond are indistinguishable, and two readings of a wall clock can go backwards when NTP steps. A duration from whichever origin the adapter chose has neither problem, and it makes every comparison in the engine a subtraction.
The origin is the adapter’s business. Nothing here reads a clock, so nothing here can disagree with one.
Implementations§
Source§impl Instant
impl Instant
Sourcepub const fn from_duration(since: Duration) -> Self
pub const fn from_duration(since: Duration) -> Self
A reading since after the clock’s origin.
Sourcepub const fn as_duration(self) -> Duration
pub const fn as_duration(self) -> Duration
The reading, as a duration from the clock’s origin.
Sourcepub const fn since(self, earlier: Self) -> Duration
pub const fn since(self, earlier: Self) -> Duration
How much time passed between earlier and self.
Saturating rather than wrapping: a clock whose second reading somehow
precedes the first should report no elapsed time, not a duration near
u64::MAX that would expire every in-flight request at once.
Trait Implementations§
impl Copy for Instant
impl Eq for Instant
Source§impl Ord for Instant
impl Ord for Instant
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for Instant
impl PartialOrd for Instant
impl StructuralPartialEq for Instant
Auto Trait Implementations§
impl Freeze for Instant
impl RefUnwindSafe for Instant
impl Send for Instant
impl Sync for Instant
impl Unpin for Instant
impl UnsafeUnpin for Instant
impl UnwindSafe for Instant
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
Mutably borrows from an owned value. Read more