pub struct Duration { /* private fields */ }Expand description
Signed nanosecond-precision duration.
Stores i64 nanoseconds. Checked constructors return None on overflow
instead of the donor’s contract abort.
Implementations§
Source§impl Duration
impl Duration
Sourcepub const fn from_nanoseconds(nanoseconds: i64) -> Self
pub const fn from_nanoseconds(nanoseconds: i64) -> Self
Construct from a signed nanosecond count.
Sourcepub const fn from_seconds(seconds: i64) -> Option<Self>
pub const fn from_seconds(seconds: i64) -> Option<Self>
Construct from whole seconds, or None on overflow.
Sourcepub const fn from_milliseconds(milliseconds: i64) -> Option<Self>
pub const fn from_milliseconds(milliseconds: i64) -> Option<Self>
Construct from whole milliseconds, or None on overflow.
Sourcepub const fn from_microseconds(microseconds: i64) -> Option<Self>
pub const fn from_microseconds(microseconds: i64) -> Option<Self>
Construct from whole microseconds, or None on overflow.
Sourcepub fn from_seconds_f64(seconds: f64) -> Option<Self>
pub fn from_seconds_f64(seconds: f64) -> Option<Self>
Construct from fractional seconds, or None when the value is not
finite or cannot be represented in i64 nanoseconds.
Sourcepub const fn nanoseconds(self) -> i64
pub const fn nanoseconds(self) -> i64
Signed nanosecond count.
Sourcepub const fn microseconds(self) -> i64
pub const fn microseconds(self) -> i64
Truncating microsecond count.
Sourcepub const fn milliseconds(self) -> i64
pub const fn milliseconds(self) -> i64
Truncating millisecond count.
Sourcepub fn to_seconds(self) -> f64
pub fn to_seconds(self) -> f64
Duration as fractional seconds.
Sourcepub fn to_milliseconds(self) -> f64
pub fn to_milliseconds(self) -> f64
Duration as fractional milliseconds.
Sourcepub fn to_microseconds(self) -> f64
pub fn to_microseconds(self) -> f64
Duration as fractional microseconds.
Sourcepub const fn checked_add(self, other: Self) -> Option<Self>
pub const fn checked_add(self, other: Self) -> Option<Self>
Checked addition, or None on overflow.
Sourcepub const fn checked_sub(self, other: Self) -> Option<Self>
pub const fn checked_sub(self, other: Self) -> Option<Self>
Checked subtraction, or None on overflow.
Trait Implementations§
impl Copy for Duration
impl Eq for Duration
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