pub struct Timestamp(/* private fields */);Expand description
A timestamp in milliseconds since Unix epoch.
This provides type safety and clear semantics for timestamp values. All timestamps in the Emergent system use this format for consistency.
Implementations§
Source§impl Timestamp
impl Timestamp
Sourcepub const fn from_millis(millis: u64) -> Self
pub const fn from_millis(millis: u64) -> Self
Creates a timestamp from milliseconds since Unix epoch.
Sourcepub fn now() -> Self
pub fn now() -> Self
Returns the current system time as a timestamp.
Returns Timestamp(0) if system time is before Unix epoch.
Sourcepub const fn duration_since(&self, other: Self) -> Option<u64>
pub const fn duration_since(&self, other: Self) -> Option<u64>
Returns the duration since another timestamp (if this one is later).
Returns None if other is after self.
Sourcepub const fn add_millis(&self, millis: u64) -> Self
pub const fn add_millis(&self, millis: u64) -> Self
Adds milliseconds to this timestamp.
Sourcepub const fn sub_millis(&self, millis: u64) -> Self
pub const fn sub_millis(&self, millis: u64) -> Self
Subtracts milliseconds from this timestamp.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Timestamp
impl<'de> Deserialize<'de> for Timestamp
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 Ord for Timestamp
impl Ord for Timestamp
Source§impl PartialOrd for Timestamp
impl PartialOrd for Timestamp
impl Copy for Timestamp
impl Eq for Timestamp
impl StructuralPartialEq for Timestamp
Auto Trait Implementations§
impl Freeze for Timestamp
impl RefUnwindSafe for Timestamp
impl Send for Timestamp
impl Sync for Timestamp
impl Unpin for Timestamp
impl UnsafeUnpin for Timestamp
impl UnwindSafe for Timestamp
Blanket Implementations§
Source§impl<T> ActonMessage for T
impl<T> ActonMessage for T
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
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§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.