pub struct TimeStamp { /* private fields */ }Expand description
A fixed point in time relative to a reference point in time.
The reference point depends on how the time stamp is created:
Clockreturn time stamp relative to the clock start.TimeStamp::nowreturns time stamp relative to the global reference point initialized by the first call to this function.- Functions that create time stamp from another time stamp return time stamp relative to the reference point of the original time stamp.
- User decides what reference point is for time spans returned by other mechanisms.
Implementations§
Source§impl TimeStamp
impl TimeStamp
Sourcepub const fn never() -> Self
pub const fn never() -> Self
Constructs the largest possible time stamp.
It is practically impossible to reach it without using artificially large time spans.
Sourcepub fn from_elapsed(nanos: u64) -> Option<Self>
pub fn from_elapsed(nanos: u64) -> Option<Self>
Constructs time stamp from number of nanoseconds elapsed since reference point in time.
Sourcepub unsafe fn new_unchecked(nanos: u64) -> Self
pub unsafe fn new_unchecked(nanos: u64) -> Self
Constructs time stamp from number of nanoseconds elapsed since reference point in time.
§Safety
nanos must not be 0.
Sourcepub fn from_duration(duration: Duration) -> Option<Self>
pub fn from_duration(duration: Duration) -> Option<Self>
Constructs time stamp from duration since reference point in time.
Sourcepub fn from_observed_duration(duration: Duration) -> Self
pub fn from_observed_duration(duration: Duration) -> Self
Constructs time stamp from duration observed by the process.
Given that duration is measured by the process, it is impossible to overflow as it would mean that process runs for more than 500 years.
§Panics
Panics if overflow occurs.
Sourcepub const fn checked_elapsed_since(self, earlier: TimeStamp) -> Option<TimeSpan>
pub const fn checked_elapsed_since(self, earlier: TimeStamp) -> Option<TimeSpan>
Returns time span elapsed since earlier point in time.
Sourcepub fn elapsed_since(self, earlier: TimeStamp) -> TimeSpan
pub fn elapsed_since(self, earlier: TimeStamp) -> TimeSpan
Returns time span elapsed since earlier point in time.
§Panics
Panics if earlier time stamp is greater than self time stamp.
Sourcepub fn elapsed_since_start(self) -> TimeSpan
pub fn elapsed_since_start(self) -> TimeSpan
Returns time span elapsed since start point in time.
Sourcepub fn nanos_since_start(self) -> u64
pub fn nanos_since_start(self) -> u64
Returns time span elapsed since start point in time.
Sourcepub fn checked_add(self, span: TimeSpan) -> Option<TimeStamp>
pub fn checked_add(self, span: TimeSpan) -> Option<TimeStamp>
Returns checked time stamp after adding given time span.
Trait Implementations§
Source§impl AddAssign<TimeSpan> for TimeStamp
impl AddAssign<TimeSpan> for TimeStamp
Source§fn add_assign(&mut self, rhs: TimeSpan)
fn add_assign(&mut self, rhs: TimeSpan)
+= operation. Read more