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

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.

Returns a Timestamp representation of the current time.

Returns a Timestamp representation of a timestamp not being set.

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.

👎Deprecated since 0.9.1:

use nanoseconds instead

Convert a Timestamp to u64 value in nanoseconds. If no timestamp is set, the result is 0.

Convert a Timestamp to u64 value in nanoseconds. If no timestamp is set, the result is 0.

use ibc::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);

Convert a Timestamp to an optional OffsetDateTime

Convert a Timestamp to an optional tendermint::Time

Checks whether the timestamp has expired when compared to the other timestamp. Returns an Expiry result.

Checks whether the current timestamp is strictly more advanced than the other timestamp. Return true if so, and false otherwise.

Trait Implementations

The resulting type after applying the + operator.

Performs the + operation. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Deserialize this value from the given Serde deserializer. Read more

Formats the value using the given formatter. Read more

Converts to this type from the input type.

The associated error which can be returned from parsing.

Parses a string s to return a value of this type. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Serialize this value into the given Serde serializer. Read more

The resulting type after applying the - operator.

Performs the - operation. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more