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
pub fn now() -> Time
Sourcepub fn unix_epoch() -> Self
pub fn unix_epoch() -> Self
Get the unix epoch (“1970-01-01 00:00:00 UTC”) as a Time
pub fn from_unix_timestamp(secs: i64, nanos: u32) -> Result<Self, 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<Self>
pub fn checked_add(self, duration: Duration) -> Option<Self>
Computes self + duration
, returning None
if an overflow occurred.
Sourcepub fn checked_sub(self, duration: Duration) -> Option<Self>
pub fn checked_sub(self, duration: Duration) -> Option<Self>
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<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Ord for Time
impl Ord for Time
Source§impl PartialOrd for Time
impl PartialOrd for Time
Source§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.