pub struct SignedDuration { /* private fields */ }Expand description
Signed nanosecond-backed duration used for derived timing values.
This type preserves negative values that can arise after subtracting server
processing time or comparing wall-clock timestamps from different hosts. It
should not be used to represent raw elapsed wall-clock or monotonic time,
which is non-negative and represented by Duration.
Implementations§
Source§impl SignedDuration
impl SignedDuration
Sourcepub const fn from_nanos(ns: i128) -> Self
pub const fn from_nanos(ns: i128) -> Self
Construct a signed duration from nanoseconds.
Sourcepub fn from_duration(duration: Duration) -> Self
pub fn from_duration(duration: Duration) -> Self
Convert a non-negative Duration into a signed duration.
Durations larger than i128::MAX nanoseconds saturate to i128::MAX.
Sourcepub const fn as_micros(self) -> i128
pub const fn as_micros(self) -> i128
Return the duration in whole microseconds, truncated toward zero.
Sourcepub const fn as_millis(self) -> i128
pub const fn as_millis(self) -> i128
Return the duration in whole milliseconds, truncated toward zero.
Sourcepub const fn is_negative(self) -> bool
pub const fn is_negative(self) -> bool
Return whether this duration is less than zero.
Trait Implementations§
Source§impl Clone for SignedDuration
impl Clone for SignedDuration
Source§fn clone(&self) -> SignedDuration
fn clone(&self) -> SignedDuration
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for SignedDuration
Source§impl Debug for SignedDuration
impl Debug for SignedDuration
impl Eq for SignedDuration
Source§impl From<Duration> for SignedDuration
impl From<Duration> for SignedDuration
Source§impl Ord for SignedDuration
impl Ord for SignedDuration
Source§fn cmp(&self, other: &SignedDuration) -> Ordering
fn cmp(&self, other: &SignedDuration) -> Ordering
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 PartialEq for SignedDuration
impl PartialEq for SignedDuration
Source§fn eq(&self, other: &SignedDuration) -> bool
fn eq(&self, other: &SignedDuration) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl PartialOrd for SignedDuration
impl PartialOrd for SignedDuration
impl StructuralPartialEq for SignedDuration
Auto Trait Implementations§
impl Freeze for SignedDuration
impl RefUnwindSafe for SignedDuration
impl Send for SignedDuration
impl Sync for SignedDuration
impl Unpin for SignedDuration
impl UnsafeUnpin for SignedDuration
impl UnwindSafe for SignedDuration
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