Struct concordium_std::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) -> Duration
pub const fn from_millis(milliseconds: u64) -> Duration
Construct duration from milliseconds.
sourcepub const fn from_seconds(seconds: u64) -> Duration
pub const fn from_seconds(seconds: u64) -> Duration
Construct duration from seconds.
sourcepub const fn from_minutes(minutes: u64) -> Duration
pub const fn from_minutes(minutes: u64) -> Duration
Construct duration from minutes.
sourcepub const fn from_hours(hours: u64) -> Duration
pub const fn from_hours(hours: u64) -> Duration
Construct duration from hours.
sourcepub fn checked_add(self, other: Duration) -> Option<Duration>
pub fn checked_add(self, other: Duration) -> Option<Duration>
Add duration. Returns None
instead of overflowing.
sourcepub fn checked_sub(self, other: Duration) -> Option<Duration>
pub fn checked_sub(self, other: Duration) -> Option<Duration>
Subtract duration. Returns None
instead of overflowing.
Trait Implementations§
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<Duration> for Duration
impl PartialEq<Duration> for Duration
source§impl PartialOrd<Duration> for Duration
impl PartialOrd<Duration> for Duration
1.0.0 · source§fn 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 more