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 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
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Copy for Duration
impl Eq for Duration
impl StructuralPartialEq for Duration
Auto Trait Implementations§
impl Freeze for Duration
impl RefUnwindSafe for Duration
impl Send for Duration
impl Sync for Duration
impl Unpin for Duration
impl UnwindSafe for Duration
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<D, S> DeserialWithState<S> for Dwhere
D: Deserial,
S: HasStateApi,
impl<D, S> DeserialWithState<S> for Dwhere
D: Deserial,
S: HasStateApi,
source§fn deserial_with_state<R>(_state: &S, source: &mut R) -> Result<D, ParseError>where
R: Read,
fn deserial_with_state<R>(_state: &S, source: &mut R) -> Result<D, ParseError>where
R: Read,
Attempt to read a structure from a given source and state, failing if
an error occurs during deserialization or reading.