Struct CoarseInstant
pub(crate) struct CoarseInstant(Instant);
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.
Tuple Fields§
§0: Instant
Trait Implementations§
§impl Add<CoarseDuration> for CoarseInstant
impl Add<CoarseDuration> for CoarseInstant
§type Output = CoarseInstant
type Output = CoarseInstant
+
operator.§fn add(self, rhs: CoarseDuration) -> CoarseInstant
fn add(self, rhs: CoarseDuration) -> CoarseInstant
+
operation. Read more§impl AddAssign<CoarseDuration> for CoarseInstant
impl AddAssign<CoarseDuration> for CoarseInstant
§fn add_assign(&mut self, rhs: CoarseDuration)
fn add_assign(&mut self, rhs: CoarseDuration)
+=
operation. Read more§impl Clone for CoarseInstant
impl Clone for CoarseInstant
§fn clone(&self) -> CoarseInstant
fn clone(&self) -> CoarseInstant
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read more§impl Debug for CoarseInstant
impl Debug for CoarseInstant
§impl Hash for CoarseInstant
impl Hash for CoarseInstant
§impl Ord for CoarseInstant
impl Ord for CoarseInstant
§impl PartialEq for CoarseInstant
impl PartialEq for CoarseInstant
§impl PartialOrd for CoarseInstant
impl PartialOrd for CoarseInstant
§impl Sub<CoarseDuration> for CoarseInstant
impl Sub<CoarseDuration> for CoarseInstant
§type Output = CoarseInstant
type Output = CoarseInstant
-
operator.§fn sub(self, rhs: CoarseDuration) -> CoarseInstant
fn sub(self, rhs: CoarseDuration) -> CoarseInstant
-
operation. Read more§impl SubAssign<CoarseDuration> for CoarseInstant
impl SubAssign<CoarseDuration> for CoarseInstant
§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,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§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> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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