Struct TimestampMs
pub struct TimestampMs(/* private fields */);Expand description
The number of milliseconds since the UNIX_EPOCH.
- Internally represented by a non-negative
i64to ease interoperability with some platforms we use which don’t support unsigned ints well (Postgres and Dart/Flutter). - Can represent any time from January 1st, 1970 00:00:00.000 UTC to roughly 292 million years in the future.
Implementations§
§impl TimestampMs
impl TimestampMs
pub const MIN: TimestampMs
pub const MAX: TimestampMs
pub fn now() -> TimestampMs
pub fn now() -> TimestampMs
Creates a new TimestampMs from the current SystemTime.
Panics if the current time is not within bounds.
pub fn from_secs(secs: u64) -> Result<TimestampMs, Error>
pub fn from_secs(secs: u64) -> Result<TimestampMs, Error>
Construct TimestampMs from seconds since Unix epoch.
pub fn from_secs_u32(secs: u32) -> TimestampMs
pub fn from_secs_u32(secs: u32) -> TimestampMs
Infallibly construct TimestampMs from seconds since Unix epoch.
pub fn from_millis(millis: u64) -> Result<TimestampMs, Error>
pub fn from_millis(millis: u64) -> Result<TimestampMs, Error>
Construct TimestampMs from milliseconds since Unix epoch.
pub fn from_duration(dur_since_epoch: Duration) -> Result<TimestampMs, Error>
pub fn from_duration(dur_since_epoch: Duration) -> Result<TimestampMs, Error>
Construct TimestampMs from Duration since Unix epoch.
pub fn from_system_time(system_time: SystemTime) -> Result<TimestampMs, Error>
pub fn from_system_time(system_time: SystemTime) -> Result<TimestampMs, Error>
Construct TimestampMs from a SystemTime.
pub fn to_duration(self) -> Duration
pub fn to_duration(self) -> Duration
Get this unix timestamp as a Duration from the unix epoch.
pub fn to_system_time(self) -> SystemTime
pub fn to_system_time(self) -> SystemTime
Get this unix timestamp as a SystemTime.
pub fn checked_add(self, duration: Duration) -> Option<TimestampMs>
pub fn checked_sub(self, duration: Duration) -> Option<TimestampMs>
pub fn saturating_add(self, duration: Duration) -> TimestampMs
pub fn saturating_sub(self, duration: Duration) -> TimestampMs
pub fn absolute_diff(self, other: TimestampMs) -> Duration
pub fn absolute_diff(self, other: TimestampMs) -> Duration
Returns the absolute difference two timestamps as a Duration.
Trait Implementations§
§impl Clone for TimestampMs
impl Clone for TimestampMs
§fn clone(&self) -> TimestampMs
fn clone(&self) -> TimestampMs
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for TimestampMs
impl Debug for TimestampMs
§impl<'de> Deserialize<'de> for TimestampMs
impl<'de> Deserialize<'de> for TimestampMs
§fn deserialize<D>(
deserializer: D,
) -> Result<TimestampMs, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<TimestampMs, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
§impl Display for TimestampMs
impl Display for TimestampMs
§impl FromStr for TimestampMs
impl FromStr for TimestampMs
§impl Hash for TimestampMs
impl Hash for TimestampMs
§impl Ord for TimestampMs
impl Ord for TimestampMs
§impl PartialEq for TimestampMs
impl PartialEq for TimestampMs
§impl PartialOrd for TimestampMs
impl PartialOrd for TimestampMs
§impl Serialize for TimestampMs
impl Serialize for TimestampMs
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
§impl TryFrom<Duration> for TimestampMs
Attempts to convert a Duration since the UNIX epoch into a
TimestampMs.
impl TryFrom<Duration> for TimestampMs
Attempts to convert a Duration since the UNIX epoch into a
TimestampMs.
Returns an error if the Duration is too large.
§impl TryFrom<SystemTime> for TimestampMs
Attempts to convert a SystemTime into a TimestampMs.
impl TryFrom<SystemTime> for TimestampMs
Attempts to convert a SystemTime into a TimestampMs.
Returns an error if the SystemTime is not within bounds.
§fn try_from(
system_time: SystemTime,
) -> Result<TimestampMs, <TimestampMs as TryFrom<SystemTime>>::Error>
fn try_from( system_time: SystemTime, ) -> Result<TimestampMs, <TimestampMs as TryFrom<SystemTime>>::Error>
§impl TryFrom<i64> for TimestampMs
Attempt to convert an i64 in milliseconds since unix epoch into a
TimestampMs.
impl TryFrom<i64> for TimestampMs
Attempt to convert an i64 in milliseconds since unix epoch into a
TimestampMs.
impl Copy for TimestampMs
impl Eq for TimestampMs
impl StructuralPartialEq for TimestampMs
Auto Trait Implementations§
impl Freeze for TimestampMs
impl RefUnwindSafe for TimestampMs
impl Send for TimestampMs
impl Sync for TimestampMs
impl Unpin for TimestampMs
impl UnwindSafe for TimestampMs
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
§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
§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.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.