pub struct Duration(/* private fields */);Expand description
Nonnegative millisecond duration. Constructors from larger units and arithmetic operators saturate; text parsing refuses overflow. No clock or timer is owned.
Implementations§
Source§impl Duration
impl Duration
Sourcepub const fn from_millis(millis: u64) -> Self
pub const fn from_millis(millis: u64) -> Self
Construct from milliseconds.
Sourcepub const fn try_from_i64(millis: i64) -> Option<Self>
pub const fn try_from_i64(millis: i64) -> Option<Self>
Convert nonnegative signed milliseconds.
Sourcepub const fn from_micros_truncating(micros: u64) -> Self
pub const fn from_micros_truncating(micros: u64) -> Self
Construct from microseconds, truncating sub-millisecond precision.
Sourcepub const fn from_nanos_truncating(nanos: u64) -> Self
pub const fn from_nanos_truncating(nanos: u64) -> Self
Construct from nanoseconds, truncating sub-millisecond precision.
Sourcepub const fn from_minutes(minutes: u64) -> Self
pub const fn from_minutes(minutes: u64) -> Self
Construct from minutes with saturation.
Sourcepub const fn from_hours(hours: u64) -> Self
pub const fn from_hours(hours: u64) -> Self
Construct from hours with saturation.
Sourcepub const fn from_weeks(weeks: u64) -> Self
pub const fn from_weeks(weeks: u64) -> Self
Construct from weeks with saturation.
Sourcepub const fn as_minutes(self) -> u64
pub const fn as_minutes(self) -> u64
Return whole minutes.
Sourcepub fn parse_flexible(input: &str) -> Result<Self, TimeParseError>
pub fn parse_flexible(input: &str) -> Result<Self, TimeParseError>
Parse integer milliseconds or ms, s, m, h, or d suffixes.
§Errors
Returns TimeParseError::InvalidDuration for malformed or overflowing
input.
Trait Implementations§
Source§impl AddAssign for Duration
impl AddAssign for Duration
Source§fn add_assign(&mut self, other: Self)
fn add_assign(&mut self, other: Self)
Performs the
+= operation. Read moreSource§impl AddAssign<Duration> for Timestamp
impl AddAssign<Duration> for Timestamp
Source§fn add_assign(&mut self, duration: Duration)
fn add_assign(&mut self, duration: Duration)
Performs the
+= operation. Read moreimpl Copy for Duration
impl Eq for Duration
Source§impl From<Duration> for IndexValue<'_>
impl From<Duration> for IndexValue<'_>
Source§impl Ord for Duration
impl Ord for Duration
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for Duration
impl PartialOrd for Duration
impl StructuralPartialEq for Duration
Auto Trait Implementations§
impl Forget for Duration
impl Freeze for Duration
impl Move for Duration
impl RefUnwindSafe for Duration
impl Send for Duration
impl Sync for Duration
impl Unpin for Duration
impl UnsafeUnpin 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