Timestamp

Struct Timestamp 

Source
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

Source

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 Add<Duration> for Timestamp

Source§

type Output = Timestamp

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Duration) -> Self::Output

Performs the + operation. Read more
Source§

impl Add for Timestamp

Source§

type Output = Timestamp

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl AddAssign<Duration> for Timestamp

Source§

fn add_assign(&mut self, rhs: Duration)

Performs the += operation. Read more
Source§

impl AddAssign for Timestamp

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Source§

impl<'arbitrary> Arbitrary<'arbitrary> for Timestamp

Source§

fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>

Generate an arbitrary value of Self from the given unstructured data. Read more
Source§

fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>

Generate an arbitrary value of Self from the entirety of the given unstructured data. Read more
Source§

fn size_hint(depth: usize) -> (usize, Option<usize>)

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
Source§

fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
Source§

impl AsMut<u64> for Timestamp

Source§

fn as_mut(&mut self) -> &mut u64

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl AsRef<u64> for Timestamp

Source§

fn as_ref(&self) -> &u64

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for Timestamp

Source§

fn clone(&self) -> Timestamp

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Timestamp

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Timestamp

Source§

fn default() -> Timestamp

Returns the “default value” for a type. Read more
Source§

impl Display for Timestamp

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<Timestamp> for Duration

Creates a duration which corresponds to the number of microsecond represented in the timestamp.

Source§

fn from(value: Timestamp) -> Self

Converts to this type from the input type.
Source§

impl From<Timestamp> for Epoch

Source§

fn from(value: Timestamp) -> Self

Converts to this type from the input type.
Source§

impl From<Timestamp> for u64

Source§

fn from(value: Timestamp) -> Self

Converts to this type from the input type.
Source§

impl From<u64> for Timestamp

Source§

fn from(value: u64) -> Self

Converts to this type from the input type.
Source§

impl GreatestElement for Timestamp

Source§

fn greatest() -> Self

Returns the unique greatest element. Read more
Source§

fn is_greatest(&self) -> bool

Returns true if and only if self is the greatest element.
Source§

impl Hash for Timestamp

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl LeastElement for Timestamp

Source§

fn least() -> Self

Returns the unique least element. Read more
Source§

fn is_least(&self) -> bool

Returns true if and only if self is the least element.
Source§

impl LowerSemilattice for Timestamp

Source§

fn greatest_lower_bound(&self, other: &Self) -> Self

Returns the greatest lower bound of 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

Source§

fn cmp(&self, other: &Timestamp) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Timestamp

Source§

fn eq(&self, other: &Timestamp) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Timestamp

Source§

fn partial_cmp(&self, other: &Timestamp) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Sub<Duration> for Timestamp

Source§

type Output = Timestamp

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Duration) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub for Timestamp

Source§

type Output = Timestamp

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl SubAssign<Duration> for Timestamp

Source§

fn sub_assign(&mut self, rhs: Duration)

Performs the -= operation. Read more
Source§

impl SubAssign for Timestamp

Source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
Source§

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§

fn try_from(value: Duration) -> Result<Self, Self::Error>

Conversion fails if the resulting timestamp would not fit into a u64.

Source§

type Error = <i128 as TryInto<u64>>::Error

The type returned in the event of a conversion error.
Source§

impl TryFrom<Epoch> for Timestamp

Conversion fails if the resulting timestamp would not fit into a u64.

Source§

fn try_from(value: Epoch) -> Result<Self, Self::Error>

Conversion fails if the resulting timestamp would not fit into a u64.

Source§

type Error = <i128 as TryInto<u64>>::Error

The type returned in the event of a conversion error.
Source§

impl TryPredecessor for Timestamp

Source§

fn try_predecessor(&self) -> Option<Self>

If 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

Returns true iff self is the predecessor of other.
Source§

fn is_not_predecessor_of(&self, other: &Self) -> bool

Returns true iff self is not the predecessor of other.
Source§

impl TrySuccessor for Timestamp

Source§

fn try_successor(&self) -> Option<Self>

If 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

Returns true iff self is the successor of other.
Source§

fn is_not_successor_of(&self, other: &Self) -> bool

Returns true iff self is not the successor of other.
Source§

impl UpperSemilattice for Timestamp

Source§

fn least_upper_bound(&self, other: &Self) -> Self

Returns the least upper bound of self and other, i.e., the unique least element in the type which is greater than or equal to both self and other.
Source§

impl Copy for Timestamp

Source§

impl Eq for Timestamp

Source§

impl PredecessorExceptForLeast for Timestamp

Source§

impl StructuralPartialEq for Timestamp

Source§

impl SuccessorExceptForGreatest for Timestamp

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> BoundedLowerSemilattice for T

Source§

fn greatest_lower_bound_slice(values: &[Self]) -> Self

Computes the greatest lower bound of all values in the slice. For the empty slice, this is the least element.
Source§

impl<T> BoundedUpperSemilattice for T

Source§

fn least_upper_bound_slice(values: &[Self]) -> Self

Computes the least upper bound of all values in the slice. For the empty slice, this is the greatest element.
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> BoundedLattice for T

Source§

impl<T> Lattice for T