pub struct CoarseInstant(/* private fields */);
Expand description
A monotonic timestamp with reduced precision, and, in the future, saturating arithmetic
Like std::time::Instant
, but:
-
RealCoarseTimeProvider::now_coarse()
is cheap on all platforms, unlikestd::time::Instant::now
. -
Not true yet: Arithmetic is saturating (so, it’s panic-free).
-
Precision and accuracy are reduced.
-
Cannot be compared with, or converted to/from,
std::time::Instant
. It has a completely different timescale toInstant
.
You can obtain this (only) from CoarseTimeProvider::now_coarse
.
§Range and precision
The range of a CoarseInstant
is not directly visible,
since the absolute value isn’t.
CoarseInstant
s are valid only within the context of one program execution (process).
Correct behaviour with processes that run for more than 2^31 seconds (about 30 years) is not guaranteed.
The precision is no worse than 1 second.
§Panics
Currently, operations on CoarseInstant
and CoarseDuration
can panic on under/overflow.
We regard this as a bug.
The intent is that all operations will saturate.
Trait Implementations§
Source§impl Add<CoarseDuration> for CoarseInstant
impl Add<CoarseDuration> for CoarseInstant
Source§type Output = CoarseInstant
type Output = CoarseInstant
+
operator.Source§fn add(self, rhs: CoarseDuration) -> CoarseInstant
fn add(self, rhs: CoarseDuration) -> CoarseInstant
+
operation. Read moreSource§impl AddAssign<CoarseDuration> for CoarseInstant
impl AddAssign<CoarseDuration> for CoarseInstant
Source§fn add_assign(&mut self, rhs: CoarseDuration)
fn add_assign(&mut self, rhs: CoarseDuration)
+=
operation. Read moreSource§impl Clone for CoarseInstant
impl Clone for CoarseInstant
Source§fn clone(&self) -> CoarseInstant
fn clone(&self) -> CoarseInstant
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for CoarseInstant
impl Debug for CoarseInstant
Source§impl Hash for CoarseInstant
impl Hash for CoarseInstant
Source§impl Ord for CoarseInstant
impl Ord for CoarseInstant
Source§fn cmp(&self, other: &CoarseInstant) -> Ordering
fn cmp(&self, other: &CoarseInstant) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for CoarseInstant
impl PartialEq for CoarseInstant
Source§impl PartialOrd for CoarseInstant
impl PartialOrd for CoarseInstant
Source§impl Sub<CoarseDuration> for CoarseInstant
impl Sub<CoarseDuration> for CoarseInstant
Source§type Output = CoarseInstant
type Output = CoarseInstant
-
operator.Source§fn sub(self, rhs: CoarseDuration) -> CoarseInstant
fn sub(self, rhs: CoarseDuration) -> CoarseInstant
-
operation. Read moreSource§impl SubAssign<CoarseDuration> for CoarseInstant
impl SubAssign<CoarseDuration> for CoarseInstant
Source§fn sub_assign(&mut self, rhs: CoarseDuration)
fn sub_assign(&mut self, rhs: CoarseDuration)
-=
operation. Read moreimpl Copy for CoarseInstant
impl Eq for CoarseInstant
impl StructuralPartialEq for CoarseInstant
Auto Trait Implementations§
impl Freeze for CoarseInstant
impl RefUnwindSafe for CoarseInstant
impl Send for CoarseInstant
impl Sync for CoarseInstant
impl Unpin for CoarseInstant
impl UnwindSafe for CoarseInstant
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<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> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
Source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<T> ErasedDestructor for Twhere
T: 'static,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 8 bytes