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.impl Copy for Time
impl Eq for Time
impl StructuralPartialEq for Time
Auto Trait Implementations§
impl Freeze for Time
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
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
)