pub struct Timestamp(/* private fields */);Expand description
A Willow Timestamp is a 64-bit unsigned integer, specifying the number of microseconds which have elapsed since the J2000 reference epoch (January 1, 2000, at noon, i.e., 12:00 TT) according to International Atomic Time (aka TAI).
This type is a thin wrapper around u64, and provides convenient interoperability with the hifitime crate.
Use the TryFrom impls to convert between Timestamp and the hifitime::Epoch and hifitime::Duration types. Use the From impls to convert from and to u64 if you need low-level access.
use willow_data_model::prelude::*;
let now = Timestamp::now().expect("The standard library should provide a valid timestamp");
let three_days_later = now + 3.days();
assert!(three_days_later > now);Implementations§
Source§impl Timestamp
impl Timestamp
Sourcepub fn now() -> Result<Self, HifitimeError>
pub fn now() -> Result<Self, HifitimeError>
Creates the timestamp corresponding to the current instant in time. WARNING: This assumes that the system time returns the time in UTC. Uses std::time::SystemTime::now under the hood.
Trait Implementations§
Source§impl AddAssign<Duration> for Timestamp
impl AddAssign<Duration> for Timestamp
Source§fn add_assign(&mut self, rhs: Duration)
fn add_assign(&mut self, rhs: Duration)
+= operation. Read moreSource§impl AddAssign for Timestamp
impl AddAssign for Timestamp
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
+= operation. Read moreSource§impl<'arbitrary> Arbitrary<'arbitrary> for Timestamp
impl<'arbitrary> Arbitrary<'arbitrary> for Timestamp
Source§fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>
fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>
Self from the given unstructured data. Read moreSource§fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>
fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>
Self from the entirety of the given
unstructured data. Read moreSource§fn size_hint(depth: usize) -> (usize, Option<usize>)
fn size_hint(depth: usize) -> (usize, Option<usize>)
Unstructured this type
needs to construct itself. Read moreSource§fn try_size_hint(
depth: usize,
) -> Result<(usize, Option<usize>), MaxRecursionReached>
fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>
Unstructured this type
needs to construct itself. Read moreSource§impl From<Timestamp> for Duration
Creates a duration which corresponds to the number of microsecond represented in the timestamp.
impl From<Timestamp> for Duration
Creates a duration which corresponds to the number of microsecond represented in the timestamp.
Source§impl GreatestElement for Timestamp
impl GreatestElement for Timestamp
Source§impl LeastElement for Timestamp
impl LeastElement for Timestamp
Source§impl LowerSemilattice for Timestamp
impl LowerSemilattice for Timestamp
Source§fn greatest_lower_bound(&self, other: &Self) -> Self
fn greatest_lower_bound(&self, other: &Self) -> Self
self and other, i.e., the unique greatest element in the type which is less than or equal to both self and other.Source§impl Ord for Timestamp
impl Ord for Timestamp
Source§impl PartialOrd for Timestamp
impl PartialOrd for Timestamp
Source§impl SubAssign<Duration> for Timestamp
impl SubAssign<Duration> for Timestamp
Source§fn sub_assign(&mut self, rhs: Duration)
fn sub_assign(&mut self, rhs: Duration)
-= operation. Read moreSource§impl SubAssign for Timestamp
impl SubAssign for Timestamp
Source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
-= operation. Read moreSource§impl TryFrom<Duration> for Timestamp
Creates a timestamp whose value is the number of microseconds in the duration. Conversion fails if the resulting timestamp would not fit into a u64.
impl TryFrom<Duration> for Timestamp
Creates a timestamp whose value is the number of microseconds in the duration. Conversion fails if the resulting timestamp would not fit into a u64.
Source§impl TryFrom<Epoch> for Timestamp
Conversion fails if the resulting timestamp would not fit into a u64.
impl TryFrom<Epoch> for Timestamp
Conversion fails if the resulting timestamp would not fit into a u64.
Source§impl TryPredecessor for Timestamp
impl TryPredecessor for Timestamp
Source§fn try_predecessor(&self) -> Option<Self>
fn try_predecessor(&self) -> Option<Self>
self has a predecessor, i.e., a unique greatest value which is strictly less than self, returns it. If there is no unique predecessor, returns None.Source§fn is_predecessor_of(&self, other: &Self) -> bool
fn is_predecessor_of(&self, other: &Self) -> bool
true iff self is the predecessor of other.Source§fn is_not_predecessor_of(&self, other: &Self) -> bool
fn is_not_predecessor_of(&self, other: &Self) -> bool
true iff self is not the predecessor of other.Source§impl TrySuccessor for Timestamp
impl TrySuccessor for Timestamp
Source§fn try_successor(&self) -> Option<Self>
fn try_successor(&self) -> Option<Self>
self has a successor, i.e., a unique least value which is strictly greater than self, returns it. If there is no unique successor, returns None.Source§fn is_successor_of(&self, other: &Self) -> bool
fn is_successor_of(&self, other: &Self) -> bool
true iff self is the successor of other.Source§fn is_not_successor_of(&self, other: &Self) -> bool
fn is_not_successor_of(&self, other: &Self) -> bool
true iff self is not the successor of other.Source§impl UpperSemilattice for Timestamp
impl UpperSemilattice for Timestamp
Source§fn least_upper_bound(&self, other: &Self) -> Self
fn least_upper_bound(&self, other: &Self) -> Self
self and other, i.e., the unique least element in the type which is greater than or equal to both self and other.