pub struct Timestamp(pub i64);Expand description
A Daml Timestamp — microseconds since the Unix epoch (UTC).
Convert to and from time::OffsetDateTime rather than doing epoch
arithmetic by hand:
use canton_daml::Timestamp;
use time::macros::datetime;
let at = Timestamp::from_datetime(datetime!(2026-07-31 12:00 UTC)).unwrap();
assert_eq!(at.to_datetime().unwrap().year(), 2026);Tuple Fields§
§0: i64Implementations§
Source§impl Timestamp
impl Timestamp
Sourcepub fn to_datetime(self) -> Option<OffsetDateTime>
pub fn to_datetime(self) -> Option<OffsetDateTime>
The instant as a UTC date-time, or None when the microsecond count is
outside the range time can represent.
Sourcepub fn from_datetime(at: OffsetDateTime) -> Option<Self>
pub fn from_datetime(at: OffsetDateTime) -> Option<Self>
The timestamp for a date-time, truncated toward the past (so
sub-microsecond digits never move an instant forward), or None when
the instant is outside the microsecond range a Daml Timestamp can
hold. Never saturates: a silent clamp would turn an out-of-range instant
into a plausible-looking wrong one.
Trait Implementations§
impl Copy for Timestamp
Source§impl<'de> Deserialize<'de> for Timestamp
impl<'de> Deserialize<'de> for Timestamp
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Timestamp
Source§impl FromValue for Timestamp
impl FromValue for Timestamp
Source§fn from_value(value: &Value) -> Result<Self, ValueError>
fn from_value(value: &Value) -> Result<Self, ValueError>
Source§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,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§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
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
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request