pub struct Timestamp { /* private fields */ }Expand description
A newtype wrapper over Option<Time> to keep track of
IBC packet timeout.
We use an explicit Option type to distinguish this when converting between
a u64 value and a raw timestamp. In protocol buffer, the timestamp is
represented as a u64 Unix timestamp in nanoseconds, with 0 representing the absence
of timestamp.
Implementations§
Source§impl Timestamp
impl Timestamp
Sourcepub fn from_nanoseconds(
nanoseconds: u64,
) -> Result<Timestamp, ParseTimestampError>
pub fn from_nanoseconds( nanoseconds: u64, ) -> Result<Timestamp, ParseTimestampError>
The IBC protocol represents timestamps as u64 Unix timestamps in nanoseconds.
A protocol value of 0 indicates that the timestamp is not set. In this case, our domain type takes the value of None.
Sourcepub fn duration_since(&self, other: &Timestamp) -> Option<Duration>
pub fn duration_since(&self, other: &Timestamp) -> Option<Duration>
Computes the duration difference of another Timestamp from the current one.
Returns the difference in time as an core::time::Duration.
Returns None if the other Timestamp is more advanced
than the current or if either of the Timestamps is not set.
Sourcepub fn as_nanoseconds(&self) -> u64
👎Deprecated since 0.9.1: use nanoseconds instead
pub fn as_nanoseconds(&self) -> u64
nanoseconds insteadConvert a Timestamp to u64 value in nanoseconds. If no timestamp
is set, the result is 0.
Sourcepub fn nanoseconds(self) -> u64
pub fn nanoseconds(self) -> u64
Convert a Timestamp to u64 value in nanoseconds. If no timestamp
is set, the result is 0.
use ibc_relayer_types::timestamp::Timestamp;
let max = u64::MAX;
let tx = Timestamp::from_nanoseconds(max).unwrap();
let utx = tx.nanoseconds();
assert_eq!(utx, max);
let min = u64::MIN;
let ti = Timestamp::from_nanoseconds(min).unwrap();
let uti = ti.nanoseconds();
assert_eq!(uti, min);
let tz = Timestamp::default();
let utz = tz.nanoseconds();
assert_eq!(utz, 0);Sourcepub fn into_datetime(self) -> Option<OffsetDateTime>
pub fn into_datetime(self) -> Option<OffsetDateTime>
Convert a Timestamp to an optional OffsetDateTime
Sourcepub fn into_tm_time(self) -> Option<Time>
pub fn into_tm_time(self) -> Option<Time>
Convert a Timestamp to an optional tendermint::Time
Sourcepub fn check_expiry(&self, other: &Timestamp) -> Expiry
pub fn check_expiry(&self, other: &Timestamp) -> Expiry
Checks whether the timestamp has expired when compared to the
other timestamp. Returns an Expiry result.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Timestamp
impl<'de> Deserialize<'de> for Timestamp
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Ord for Timestamp
impl Ord for Timestamp
Source§impl PartialOrd for Timestamp
impl PartialOrd for Timestamp
impl Copy for Timestamp
impl Eq 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 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
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§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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.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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§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>
T in a tonic::Request