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.
CoarseInstants 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 more