pub struct TimestampDuration(/* private fields */);Expand description
8-byte-aligned u64 newtype that serializes as a string for JSON safety.
Implementations§
Source§impl TimestampDuration
impl TimestampDuration
Sourcepub fn since(older: Timestamp) -> Self
pub fn since(older: Timestamp) -> Self
Elapsed time from older to now, saturating to zero if older is in the future.
Sourcepub fn since_non_decreasing(older: Timestamp) -> Self
pub fn since_non_decreasing(older: Timestamp) -> Self
Elapsed time from older to a non-decreasing now, saturating to zero if older is in the future.
Sourcepub fn seconds_u32(&self) -> Result<u32, String>
pub fn seconds_u32(&self) -> Result<u32, String>
Whole seconds as a u32, erroring if the value overflows.
Sourcepub fn millis_u32(&self) -> Result<u32, String>
pub fn millis_u32(&self) -> Result<u32, String>
Whole milliseconds as a u32, erroring if the value overflows.
Sourcepub fn seconds_f64(&self) -> f64
pub fn seconds_f64(&self) -> f64
Seconds as an f64, trading off least significant bits for range.
Sourcepub const fn saturating_add(self, rhs: Self) -> Self
pub const fn saturating_add(self, rhs: Self) -> Self
Add two durations, saturating at the maximum value.
Sourcepub const fn saturating_sub(self, rhs: Self) -> Self
pub const fn saturating_sub(self, rhs: Self) -> Self
Subtract a duration, saturating at zero.
Sourcepub const fn saturating_mul(self, rhs: u64) -> Self
pub const fn saturating_mul(self, rhs: u64) -> Self
Multiply by a scalar, saturating at the maximum value.
Sourcepub fn f64_mul(self, rhs: f64) -> Self
pub fn f64_mul(self, rhs: f64) -> Self
Multiply by an f64 scaling factor (not const due to float arithmetic)
Sourcepub const fn div_assign(&mut self, rhs: u64)
pub const fn div_assign(&mut self, rhs: u64)
Divide by a scalar in place.
Sourcepub fn checked_div<T: Into<u64>>(self, rhs: T) -> Option<Self>
pub fn checked_div<T: Into<u64>>(self, rhs: T) -> Option<Self>
Divide by a scalar, returning None on divide by zero.
Sourcepub fn checked_mul<T: Into<u64>>(self, rhs: T) -> Option<Self>
pub fn checked_mul<T: Into<u64>>(self, rhs: T) -> Option<Self>
Multiply by a scalar, returning None on overflow.
Sourcepub const fn saturating_add_assign(&mut self, rhs: Self)
pub const fn saturating_add_assign(&mut self, rhs: Self)
Add a duration in place, saturating at the maximum value.
Sourcepub const fn saturating_sub_assign(&mut self, rhs: Self)
pub const fn saturating_sub_assign(&mut self, rhs: Self)
Subtract a duration in place, saturating at zero.
Sourcepub const fn saturating_mul_assign(&mut self, rhs: u64)
pub const fn saturating_mul_assign(&mut self, rhs: u64)
Multiply by a scalar in place, saturating at the maximum value.
Trait Implementations§
Source§impl Clone for TimestampDuration
impl Clone for TimestampDuration
Source§fn clone(&self) -> TimestampDuration
fn clone(&self) -> TimestampDuration
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for TimestampDuration
Source§impl Debug for TimestampDuration
impl Debug for TimestampDuration
Source§impl Default for TimestampDuration
impl Default for TimestampDuration
Source§fn default() -> TimestampDuration
fn default() -> TimestampDuration
Source§impl<'de> Deserialize<'de> for TimestampDuration
impl<'de> Deserialize<'de> for TimestampDuration
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for TimestampDuration
impl Display for TimestampDuration
impl Eq for TimestampDuration
Source§impl From<TimestampDuration> for u64
impl From<TimestampDuration> for u64
Source§fn from(v: TimestampDuration) -> Self
fn from(v: TimestampDuration) -> Self
Source§impl From<u64> for TimestampDuration
impl From<u64> for TimestampDuration
Source§impl FromStr for TimestampDuration
impl FromStr for TimestampDuration
Source§impl GetSize for TimestampDuration
impl GetSize for TimestampDuration
Source§fn get_heap_size(&self) -> usize
fn get_heap_size(&self) -> usize
Source§fn get_heap_size_with_tracker<TRACKER: GetSizeTracker>(
&self,
tracker: TRACKER,
) -> (usize, TRACKER)
fn get_heap_size_with_tracker<TRACKER: GetSizeTracker>( &self, tracker: TRACKER, ) -> (usize, TRACKER)
tracker. Read moreSource§fn get_stack_size() -> usize
fn get_stack_size() -> usize
Source§fn get_size_with_tracker<T>(&self, tracker: T) -> (usize, T)where
T: GetSizeTracker,
fn get_size_with_tracker<T>(&self, tracker: T) -> (usize, T)where
T: GetSizeTracker,
tracker. Read moreSource§impl Hash for TimestampDuration
impl Hash for TimestampDuration
Source§impl Ord for TimestampDuration
impl Ord for TimestampDuration
Source§fn cmp(&self, other: &TimestampDuration) -> Ordering
fn cmp(&self, other: &TimestampDuration) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for TimestampDuration
impl PartialEq for TimestampDuration
Source§impl PartialOrd for TimestampDuration
impl PartialOrd for TimestampDuration
Source§impl Serialize for TimestampDuration
impl Serialize for TimestampDuration
impl StructuralPartialEq for TimestampDuration
Source§impl ToVeilidAPIErrorArgument for TimestampDuration
impl ToVeilidAPIErrorArgument for TimestampDuration
Source§fn to_veilid_api_error_argument(&self) -> String
fn to_veilid_api_error_argument(&self) -> String
Auto Trait Implementations§
impl Freeze for TimestampDuration
impl RefUnwindSafe for TimestampDuration
impl Send for TimestampDuration
impl Sync for TimestampDuration
impl Unpin for TimestampDuration
impl UnsafeUnpin for TimestampDuration
impl UnwindSafe for TimestampDuration
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> CmpAssign for Twhere
T: Ord,
impl<T> CmpAssign for Twhere
T: Ord,
Source§fn min_assign(&mut self, other: T)
fn min_assign(&mut self, other: T)
self with other if other is smaller.Source§fn max_assign(&mut self, other: T)
fn max_assign(&mut self, other: T)
self with other if other is larger.Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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> 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