Struct tendermint_light_client::types::Time
source · pub struct Time(/* private fields */);Expand description
Tendermint timestamps
A Time value is guaranteed to represent a valid Timestamp as defined
by Google’s well-known protobuf type specification. Conversions and
operations that would result in exceeding Timestamp’s validity
range return an error or None.
The string serialization format for Time is defined as an RFC 3339
compliant string with the optional subsecond fraction part having
up to 9 digits and no trailing zeros, and the UTC offset denoted by Z.
This reproduces the behavior of Go’s time.RFC3339Nano format.
Implementations§
source§impl Time
impl Time
sourcepub fn unix_epoch() -> Time
pub fn unix_epoch() -> Time
Get the unix epoch (“1970-01-01 00:00:00 UTC”) as a Time
pub fn from_unix_timestamp(secs: i64, nanos: u32) -> Result<Time, Error>
sourcepub fn duration_since(&self, other: Time) -> Result<Duration, Error>
pub fn duration_since(&self, other: Time) -> Result<Duration, Error>
Calculate the amount of time which has passed since another Time
as a core::time::Duration
sourcepub fn to_rfc3339(&self) -> String
pub fn to_rfc3339(&self) -> String
Return an RFC 3339 and ISO 8601 date and time string with subseconds (if nonzero) and Z.
sourcepub fn unix_timestamp(&self) -> i64
pub fn unix_timestamp(&self) -> i64
Return a Unix timestamp in seconds.
sourcepub fn unix_timestamp_nanos(&self) -> i128
pub fn unix_timestamp_nanos(&self) -> i128
Return a Unix timestamp in nanoseconds.
sourcepub fn checked_add(self, duration: Duration) -> Option<Time>
pub fn checked_add(self, duration: Duration) -> Option<Time>
Computes self + duration, returning None if an overflow occurred.
sourcepub fn checked_sub(self, duration: Duration) -> Option<Time>
pub fn checked_sub(self, duration: Duration) -> Option<Time>
Computes self - duration, returning None if an overflow occurred.
Trait Implementations§
source§impl<'de> Deserialize<'de> for Time
impl<'de> Deserialize<'de> for Time
source§fn deserialize<__D>(
__deserializer: __D
) -> Result<Time, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>( __deserializer: __D ) -> Result<Time, <__D as Deserializer<'de>>::Error>where __D: Deserializer<'de>,
source§impl Ord for Time
impl Ord for Time
source§impl PartialEq for Time
impl PartialEq for Time
source§impl PartialOrd for Time
impl PartialOrd for Time
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read moresource§impl Protobuf<Timestamp> for Time
impl Protobuf<Timestamp> for Time
§fn encode<B>(self, buf: &mut B) -> Result<(), Error>where
B: BufMut,
fn encode<B>(self, buf: &mut B) -> Result<(), Error>where B: BufMut,
§fn encode_length_delimited<B>(self, buf: &mut B) -> Result<(), Error>where
B: BufMut,
fn encode_length_delimited<B>(self, buf: &mut B) -> Result<(), Error>where B: BufMut,
§fn decode<B>(buf: B) -> Result<Self, Error>where
B: Buf,
fn decode<B>(buf: B) -> Result<Self, Error>where B: Buf,
§fn decode_length_delimited<B>(buf: B) -> Result<Self, Error>where
B: Buf,
fn decode_length_delimited<B>(buf: B) -> Result<Self, Error>where B: Buf,
§fn encoded_len(self) -> usize
fn encoded_len(self) -> usize
§fn encode_vec(self) -> Vec<u8>
fn encode_vec(self) -> Vec<u8>
Vec<u8>.§fn decode_vec(v: &[u8]) -> Result<Self, Error>
fn decode_vec(v: &[u8]) -> Result<Self, Error>
Vec<u8> (or equivalent).§fn encode_length_delimited_vec(self) -> Vec<u8>
fn encode_length_delimited_vec(self) -> Vec<u8>
Vec<u8> Protobuf-encoded message.§fn decode_length_delimited_vec(v: &[u8]) -> Result<Self, Error>
fn decode_length_delimited_vec(v: &[u8]) -> Result<Self, Error>
Vec<u8> or equivalent.source§impl Serialize for Time
impl Serialize for Time
source§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,
source§impl TryFrom<OffsetDateTime> for Time
impl TryFrom<OffsetDateTime> for Time
impl Copy for Time
impl Eq for Time
impl StructuralEq for Time
impl StructuralPartialEq for Time
Auto Trait Implementations§
impl RefUnwindSafe for Time
impl Send for Time
impl Sync for Time
impl Unpin for Time
impl UnwindSafe for Time
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
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.