Struct Timestamp
pub struct Timestamp(/* private fields */);Expand description
A point in time, as nanoseconds since the Unix epoch, UTC.
Exchanges publish timestamps in seconds, milliseconds, microseconds, and
nanoseconds. maxt converts all of them to nanoseconds, so events from two
exchanges can be ordered against each other without knowing which exchange
they came from.
Convert at the boundary with Timestamp::as_nanos or
Timestamp::into_system_time.
Implementations§
§impl Timestamp
impl Timestamp
pub const fn from_nanos(nanos: i64) -> Self
pub const fn from_nanos(nanos: i64) -> Self
From nanoseconds since the Unix epoch.
pub const fn from_micros(micros: i64) -> Self
pub const fn from_micros(micros: i64) -> Self
From microseconds since the Unix epoch.
Saturates on overflow; see Timestamp::from_secs.
pub const fn from_millis(millis: i64) -> Self
pub const fn from_millis(millis: i64) -> Self
From milliseconds since the Unix epoch.
Saturates on overflow; see Timestamp::from_secs.
pub const fn from_secs(secs: i64) -> Self
pub const fn from_secs(secs: i64) -> Self
From whole seconds since the Unix epoch.
Values outside the nanosecond range saturate. This constructor does not report overflow.
pub fn now() -> Self
pub fn now() -> Self
The current time, read from the system clock.
Times before the Unix epoch map to the epoch. Later values that exceed the representable range saturate.
pub fn into_system_time(self) -> Option<SystemTime>
pub fn into_system_time(self) -> Option<SystemTime>
Converts to a SystemTime.
Returns None for timestamps before the Unix epoch.
This stays on std::time::SystemTime so the public type is the same
on every target: only now is unimplemented on wasm, and epoch
arithmetic is not.
Trait Implementations§
impl Copy for Timestamp
§impl Display for Timestamp
Renders as an RFC 3339 instant in UTC, to millisecond precision.
impl Display for Timestamp
Renders as an RFC 3339 instant in UTC, to millisecond precision.
The sub-millisecond part is not shown, so this form does not round-trip.
Use Timestamp::as_nanos whenever the exact value matters.
impl Eq for Timestamp
§impl Ord for Timestamp
impl Ord for Timestamp
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
§impl PartialOrd for Timestamp
impl PartialOrd 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> 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<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§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.