Struct concordium_contracts_common::Duration
source · [−]#[repr(transparent)]pub struct Duration { /* private fields */ }
Expand description
Duration of time in milliseconds.
Negative durations are not allowed.
Implementations
sourceimpl Duration
impl Duration
sourcepub fn from_millis(milliseconds: u64) -> Self
pub fn from_millis(milliseconds: u64) -> Self
Construct duration from milliseconds.
sourcepub fn from_seconds(seconds: u64) -> Self
pub fn from_seconds(seconds: u64) -> Self
Construct duration from seconds.
sourcepub fn from_minutes(minutes: u64) -> Self
pub fn from_minutes(minutes: u64) -> Self
Construct duration from minutes.
sourcepub fn from_hours(hours: u64) -> Self
pub 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
sourceimpl 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"
sourceimpl Ord for Duration
impl Ord for Duration
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) -> Self where
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl PartialEq<Duration> for Duration
impl PartialEq<Duration> for Duration
sourceimpl PartialOrd<Duration> for Duration
impl PartialOrd<Duration> for Duration
sourcefn partial_cmp(&self, other: &Duration) -> Option<Ordering>
fn partial_cmp(&self, other: &Duration) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
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 more
impl Copy for Duration
impl Eq for Duration
impl StructuralEq for Duration
impl StructuralPartialEq for Duration
Auto Trait Implementations
impl RefUnwindSafe for Duration
impl Send for Duration
impl Sync for Duration
impl Unpin for Duration
impl UnwindSafe for Duration
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
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