#[repr(C)]pub struct UnixNanos(/* private fields */);
Expand description
Represents a timestamp in nanoseconds since the UNIX epoch.
Implementations§
Source§impl UnixNanos
impl UnixNanos
Sourcepub const fn as_i64(&self) -> i64
pub const fn as_i64(&self) -> i64
Returns the underlying value as i64
.
§Panics
Panics if the value exceeds i64::MAX
(approximately year 2262).
Sourcepub const fn to_datetime_utc(&self) -> DateTime<Utc>
pub const fn to_datetime_utc(&self) -> DateTime<Utc>
Converts the underlying value to a datetime (UTC).
Sourcepub fn to_rfc3339(&self) -> String
pub fn to_rfc3339(&self) -> String
Converts the underlying value to an ISO 8601 (RFC 3339) string.
Sourcepub const fn duration_since(&self, other: &Self) -> Option<DurationNanos>
pub const fn duration_since(&self, other: &Self) -> Option<DurationNanos>
Calculates the duration in nanoseconds since another UnixNanos
instance.
Returns Some(duration)
if self
is later than other
, otherwise None
if other
is
greater than self
(indicating a negative duration is not possible with DurationNanos
).
Sourcepub fn checked_add<T: Into<u64>>(self, rhs: T) -> Option<Self>
pub fn checked_add<T: Into<u64>>(self, rhs: T) -> Option<Self>
Returns Some(self + rhs)
or None
if the addition would overflow
Sourcepub fn checked_sub<T: Into<u64>>(self, rhs: T) -> Option<Self>
pub fn checked_sub<T: Into<u64>>(self, rhs: T) -> Option<Self>
Returns Some(self - rhs)
or None
if the subtraction would underflow
Sourcepub fn saturating_add_ns<T: Into<u64>>(self, rhs: T) -> Self
pub fn saturating_add_ns<T: Into<u64>>(self, rhs: T) -> Self
Saturating addition – if overflow occurs the value is clamped to u64::MAX
.
Sourcepub fn saturating_sub_ns<T: Into<u64>>(self, rhs: T) -> Self
pub fn saturating_sub_ns<T: Into<u64>>(self, rhs: T) -> Self
Saturating subtraction – if underflow occurs the value is clamped to 0
.
Trait Implementations§
Source§impl<T: Into<u64>> AddAssign<T> for UnixNanos
impl<T: Into<u64>> AddAssign<T> for UnixNanos
Source§fn add_assign(&mut self, other: T)
fn add_assign(&mut self, other: T)
+=
operation. Read moreSource§impl<'de> Deserialize<'de> for UnixNanos
impl<'de> Deserialize<'de> for UnixNanos
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 Ord for UnixNanos
impl Ord for UnixNanos
Source§impl PartialOrd<Option<u64>> for UnixNanos
impl PartialOrd<Option<u64>> for UnixNanos
Source§impl PartialOrd<UnixNanos> for u64
impl PartialOrd<UnixNanos> for u64
Source§impl PartialOrd<u64> for UnixNanos
impl PartialOrd<u64> for UnixNanos
Source§impl PartialOrd for UnixNanos
impl PartialOrd for UnixNanos
Source§impl<T: Into<u64>> SubAssign<T> for UnixNanos
impl<T: Into<u64>> SubAssign<T> for UnixNanos
Source§fn sub_assign(&mut self, other: T)
fn sub_assign(&mut self, other: T)
-=
operation. Read moreimpl Copy for UnixNanos
impl Eq for UnixNanos
impl StructuralPartialEq for UnixNanos
Auto Trait Implementations§
impl Freeze for UnixNanos
impl RefUnwindSafe for UnixNanos
impl Send for UnixNanos
impl Sync for UnixNanos
impl Unpin for UnixNanos
impl UnwindSafe for UnixNanos
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
key
and return true
if they are equal.