Struct concordium_contracts_common::Duration
source · pub struct Duration { /* private fields */ }
Expand description
Duration of time in milliseconds.
Negative durations are not allowed.
Implementations§
source§impl Duration
impl Duration
sourcepub const fn from_millis(milliseconds: u64) -> Self
pub const fn from_millis(milliseconds: u64) -> Self
Construct duration from milliseconds.
sourcepub const fn from_seconds(seconds: u64) -> Self
pub const fn from_seconds(seconds: u64) -> Self
Construct duration from seconds.
sourcepub const fn from_minutes(minutes: u64) -> Self
pub const fn from_minutes(minutes: u64) -> Self
Construct duration from minutes.
sourcepub const fn from_hours(hours: u64) -> Self
pub const fn from_hours(hours: u64) -> Self
Construct duration from hours.
sourcepub fn checked_add(self, other: Duration) -> Option<Self>
pub fn checked_add(self, other: Duration) -> Option<Self>
Add duration. Returns None
instead of overflowing.
sourcepub fn checked_sub(self, other: Duration) -> Option<Self>
pub fn checked_sub(self, other: Duration) -> Option<Self>
Subtract duration. Returns None
instead of overflowing.
Trait Implementations§
source§impl<'de> Deserialize<'de> for Duration
impl<'de> Deserialize<'de> for Duration
Deserialize using from_str
implementation of Duration
.
source§fn deserialize<D: Deserializer<'de>>(des: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(des: D) -> Result<Self, D::Error>
source§impl FromStr for Duration
impl FromStr for Duration
Parse a string containing a list of duration measures separated by whitespaces. A measure is a number followed by the unit (no whitespace between is allowed). Every measure is accumulated into a duration. The string is allowed to contain any number of measures with the same unit in no particular order.
The supported units are:
ms
for millisecondss
for secondsm
for minutesh
for hoursd
for days
§Example
The duration of 10 days, 1 hour, 2minutes and 7 seconds is:
"10d 1h 2m 3s 4s"
source§impl Ord for Duration
impl Ord for Duration
source§impl PartialEq for Duration
impl PartialEq for Duration
source§impl PartialOrd for Duration
impl PartialOrd for Duration
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 Serialize for Duration
impl Serialize for Duration
The JSON serialization serialized the string obtained by using the Display implementation of the Duration.