Struct Timestamp
pub struct Timestamp {
pub time: Option<Time>,
}
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.
Fields§
§time: Option<Time>
Implementations§
§impl Timestamp
impl Timestamp
pub 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.
pub fn now() -> Timestamp
Available on crate feature std
only.
pub fn now() -> Timestamp
std
only.Returns a Timestamp
representation of the current time.
pub 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 Timestamp
s is not set.
pub 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.
pub 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.
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);
pub fn into_datetime(self) -> Option<OffsetDateTime>
pub fn into_datetime(self) -> Option<OffsetDateTime>
Convert a Timestamp
to an optional [OffsetDateTime
]
pub fn into_tm_time(self) -> Option<Time>
pub fn into_tm_time(self) -> Option<Time>
Convert a Timestamp
to an optional tendermint::Time
pub 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§
§impl<'de> Deserialize<'de> for Timestamp
impl<'de> Deserialize<'de> for Timestamp
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Timestamp, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Timestamp, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl Serialize for Timestamp
impl Serialize for Timestamp
§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 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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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.§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>
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>
T
in a tonic::Request