pub struct Duration(/* private fields */);Expand description
Canonical millisecond duration.
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, TypeParseError>
pub fn parse_flexible(input: &str) -> Result<Self, TypeParseError>
Parse integer milliseconds or ms, s, m, h, or d suffixes.
§Errors
Returns TypeParseError::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 moreSource§impl CandidType for Duration
impl CandidType for Duration
impl Copy for Duration
Source§impl<'de> Deserialize<'de> for Duration
impl<'de> Deserialize<'de> for Duration
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Duration
Source§impl NumericValue for Duration
impl NumericValue for Duration
Source§fn try_to_decimal(&self) -> Option<Decimal>
fn try_to_decimal(&self) -> Option<Decimal>
Convert this value into
Decimal for generic numeric handling.Source§fn try_from_decimal(value: Decimal) -> Option<Self>
fn try_from_decimal(value: Decimal) -> Option<Self>
Rebuild the value from
Decimal after generic numeric handling.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
Source§impl PartialOrd for Duration
impl PartialOrd 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 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