Struct cosmwasm_std::Timestamp
source · [−]pub struct Timestamp(_);
Expand description
A point in time in nanosecond precision.
This type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.
Examples
let ts = Timestamp::from_nanos(1_000_000_202);
assert_eq!(ts.nanos(), 1_000_000_202);
assert_eq!(ts.seconds(), 1);
assert_eq!(ts.subsec_nanos(), 202);
let ts = ts.plus_seconds(2);
assert_eq!(ts.nanos(), 3_000_000_202);
assert_eq!(ts.seconds(), 3);
assert_eq!(ts.subsec_nanos(), 202);
Implementations
sourceimpl Timestamp
impl Timestamp
sourcepub const fn from_nanos(nanos_since_epoch: u64) -> Self
pub const fn from_nanos(nanos_since_epoch: u64) -> Self
Creates a timestamp from nanoseconds since epoch
sourcepub const fn from_seconds(seconds_since_epoch: u64) -> Self
pub const fn from_seconds(seconds_since_epoch: u64) -> Self
Creates a timestamp from seconds since epoch
pub const fn plus_seconds(&self, addition: u64) -> Timestamp
pub const fn plus_nanos(&self, addition: u64) -> Timestamp
pub const fn minus_seconds(&self, subtrahend: u64) -> Timestamp
pub const fn minus_nanos(&self, subtrahend: u64) -> Timestamp
sourcepub fn subsec_nanos(&self) -> u64
pub fn subsec_nanos(&self) -> u64
Returns nanoseconds since the last whole second (the remainder truncated
by seconds()
)
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Timestamp
impl<'de> Deserialize<'de> for Timestamp
sourcefn 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>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl From<Timestamp> for IbcTimeout
impl From<Timestamp> for IbcTimeout
sourcefn from(timestamp: Timestamp) -> IbcTimeout
fn from(timestamp: Timestamp) -> IbcTimeout
Converts to this type from the input type.
sourceimpl JsonSchema for Timestamp
impl JsonSchema for Timestamp
sourcefn schema_name() -> String
fn schema_name() -> String
The name of the generated JSON Schema. Read more
sourcefn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
sourcefn is_referenceable() -> bool
fn is_referenceable() -> bool
Whether JSON Schemas generated for this type should be re-used where possible using the
$ref
keyword. Read moresourceimpl Ord for Timestamp
impl Ord for Timestamp
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl PartialOrd<Timestamp> for Timestamp
impl PartialOrd<Timestamp> for Timestamp
sourcefn partial_cmp(&self, other: &Timestamp) -> Option<Ordering>
fn partial_cmp(&self, other: &Timestamp) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Copy for Timestamp
impl Eq for Timestamp
impl StructuralEq for Timestamp
impl StructuralPartialEq for Timestamp
Auto Trait Implementations
impl RefUnwindSafe for Timestamp
impl Send for Timestamp
impl Sync for Timestamp
impl Unpin for Timestamp
impl UnwindSafe for Timestamp
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more