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
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.
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 PartialOrd for Duration
impl PartialOrd for Duration
impl 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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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.