Struct s2n_quic_core::time::Timestamp
source · [−]pub struct Timestamp(_);Expand description
An absolute point in time.
The absolute value of Timestamps should be treated as opaque. It is not
necessarily related to any calendar time.
Timestamps should only be compared if they are are sourced from the same
clock.
Timestamps are similar to the Instant data-type in the Rust standard
library, but can be created even without an available standard library.
The size of Timestamp is guaranteed to be consistent across platforms.
Implementations
sourceimpl Timestamp
impl Timestamp
sourcepub fn checked_add(self, duration: Duration) -> Option<Self>
pub fn checked_add(self, duration: Duration) -> Option<Self>
Tries to calculate a Timestamp based on the current Timestamp and
adding the provided Duration. If this Timestamp is representable
within the range of Timestamp it is returned as Some(timestamp).
Otherwise None is returned.
sourcepub fn checked_sub(self, duration: Duration) -> Option<Self>
pub fn checked_sub(self, duration: Duration) -> Option<Self>
Tries to calculate a Timestamp based on the current Timestamp and
subtracting the provided Duration. If this Timestamp is representable
within the range of Timestamp it is returned as Some(timestamp).
Otherwise None is returned.
sourcepub fn saturating_duration_since(self, earlier: Self) -> Duration
pub fn saturating_duration_since(self, earlier: Self) -> Duration
Returns the Duration which elapsed since an earlier Timestamp.
If earlier is more recent, the method returns a Duration of 0.
sourcepub unsafe fn from_duration(duration: Duration) -> Self
pub unsafe fn from_duration(duration: Duration) -> Self
Creates a Timestamp from a Duration since the time source’s epoch.
This will treat the duration as an absolute point in time.
Safety
This should only be used by time sources
sourcepub unsafe fn as_duration(self) -> Duration
pub unsafe fn as_duration(self) -> Duration
Converts the Timestamp into the Duration since the time source’s epoch.
Safety
This should only be used by time sources
sourcepub const fn has_elapsed(self, now: Self) -> bool
pub const fn has_elapsed(self, now: Self) -> bool
Compares the timestamp to the current time and returns true if it is in the past
Note that this compares milliseconds, as any finer resolution would result in excessive timer churn.
Trait Implementations
sourceimpl AddAssign<Duration> for Timestamp
impl AddAssign<Duration> for Timestamp
sourcefn add_assign(&mut self, other: Duration)
fn add_assign(&mut self, other: Duration)
Performs the += operation. Read more
sourceimpl Ord for Timestamp
impl Ord for Timestamp
sourceimpl PartialOrd<Timestamp> for Timestamp
impl PartialOrd<Timestamp> for Timestamp
sourcefn partial_cmp(&self, other: &Timestamp) -> Option<Ordering>
fn partial_cmp(&self, other: &Timestamp) -> Option<Ordering>
This method returns an ordering between self and other values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self and other) and is used by the <=
operator. Read more
sourceimpl SubAssign<Duration> for Timestamp
impl SubAssign<Duration> for Timestamp
sourcefn sub_assign(&mut self, other: Duration)
fn sub_assign(&mut self, other: Duration)
Performs the -= operation. Read more
impl Copy for Timestamp
impl Eq for Timestamp
impl StructuralEq for Timestamp
impl StructuralPartialEq for Timestamp
Auto Trait Implementations
impl RefUnwindSafe for Timestamp
impl Send for Timestamp
impl Sync for Timestamp
impl Unpin for Timestamp
impl UnwindSafe for Timestamp
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more