pub struct TimestampMs(/* private fields */);Expand description
An absolute point in time, measured in milliseconds since the Unix epoch.
Implementations§
Source§impl TimestampMs
impl TimestampMs
Sourcepub const fn new(millis: u64) -> Self
pub const fn new(millis: u64) -> Self
Creates a timestamp from raw milliseconds since the Unix epoch.
Sourcepub const fn to_le_bytes(self) -> [u8; 8]
pub const fn to_le_bytes(self) -> [u8; 8]
Returns the milliseconds as little-endian bytes.
Sourcepub const fn from_le_bytes(bytes: [u8; 8]) -> Self
pub const fn from_le_bytes(bytes: [u8; 8]) -> Self
Constructs from little-endian milliseconds bytes.
Sourcepub const fn saturating_add(self, rhs: DurationMs) -> Self
pub const fn saturating_add(self, rhs: DurationMs) -> Self
Advances this instant by rhs, saturating at TimestampMs::MAX.
Sourcepub const fn saturating_sub(self, rhs: DurationMs) -> Self
pub const fn saturating_sub(self, rhs: DurationMs) -> Self
Moves this instant back by rhs, saturating at TimestampMs::ZERO.
Sourcepub const fn checked_sub(self, rhs: DurationMs) -> Option<Self>
pub const fn checked_sub(self, rhs: DurationMs) -> Option<Self>
Moves this instant back by rhs, returning None on underflow.
Sourcepub const fn checked_add(self, rhs: DurationMs) -> Option<Self>
pub const fn checked_add(self, rhs: DurationMs) -> Option<Self>
Advances this instant by rhs, returning None on overflow.
Sourcepub const fn saturating_duration_since(self, earlier: Self) -> DurationMs
pub const fn saturating_duration_since(self, earlier: Self) -> DurationMs
Returns the duration elapsed from earlier to self, saturating at
DurationMs::ZERO if earlier is later than self.
Trait Implementations§
Source§impl Add<DurationMs> for TimestampMs
impl Add<DurationMs> for TimestampMs
Source§type Output = TimestampMs
type Output = TimestampMs
The resulting type after applying the
+ operator.Source§impl BorshDeserialize for TimestampMs
impl BorshDeserialize for TimestampMs
fn deserialize_reader<__R: Read>(reader: &mut __R) -> Result<Self, Error>
Source§fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
Deserializes this instance from a given slice of bytes.
Updates the buffer to point at the remaining bytes.
Source§fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_slice(v: &[u8]) -> Result<Self, Error>
Deserialize this instance from a slice of bytes.
fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>where
R: Read,
Source§impl BorshSerialize for TimestampMs
impl BorshSerialize for TimestampMs
Source§impl Clone for TimestampMs
impl Clone for TimestampMs
impl Copy for TimestampMs
Source§impl Debug for TimestampMs
impl Debug for TimestampMs
Source§impl Default for TimestampMs
impl Default for TimestampMs
Source§impl<'de> Deserialize<'de> for TimestampMs
impl<'de> Deserialize<'de> for TimestampMs
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for TimestampMs
impl Display for TimestampMs
impl Eq for TimestampMs
Source§impl From<TimestampMs> for u64
impl From<TimestampMs> for u64
Source§fn from(ts: TimestampMs) -> Self
fn from(ts: TimestampMs) -> Self
Converts to this type from the input type.
Source§impl From<u64> for TimestampMs
impl From<u64> for TimestampMs
Source§impl FromStr for TimestampMs
impl FromStr for TimestampMs
Source§impl Hash for TimestampMs
impl Hash for TimestampMs
Source§impl Ord for TimestampMs
impl Ord for TimestampMs
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialEq for TimestampMs
impl PartialEq for TimestampMs
Source§impl PartialOrd for TimestampMs
impl PartialOrd for TimestampMs
Source§impl Serialize for TimestampMs
impl Serialize for TimestampMs
impl StructuralPartialEq for TimestampMs
Source§impl Sub for TimestampMs
impl Sub for TimestampMs
Source§type Output = DurationMs
type Output = DurationMs
The resulting type after applying the
- operator.Source§impl Sub<DurationMs> for TimestampMs
impl Sub<DurationMs> for TimestampMs
Source§type Output = TimestampMs
type Output = TimestampMs
The resulting type after applying the
- operator.Auto Trait Implementations§
impl Freeze for TimestampMs
impl RefUnwindSafe for TimestampMs
impl Send for TimestampMs
impl Sync for TimestampMs
impl Unpin for TimestampMs
impl UnsafeUnpin for TimestampMs
impl UnwindSafe for TimestampMs
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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
Compare self to
key and return true if they are equal.