pub trait Duration:
'static
+ Sized
+ Copy
+ Clone
+ Debug
+ Add<Output = Self>
+ AddAssign
+ Sub<Output = Self>
+ SubAssign
+ Mul<u32>
+ MulAssign<u32>
+ Div<u32>
+ DivAssign<u32>
+ PartialOrd
+ Ord
+ PartialEq
+ Eq
+ Hash {
const MAX: Self;
const NANOSECOND: Self;
const MICROSECOND: Self;
const MILLISECOND: Self;
const SECOND: Self;
const ZERO: Self;
Show 19 methods
// Required methods
fn as_micros(&self) -> u128;
fn as_millis(&self) -> u128;
fn as_nanos(&self) -> u128;
fn as_secs(&self) -> u64;
fn checked_add(self, rhs: Self) -> Option<Self>;
fn checked_div(self, rhs: u32) -> Option<Self>;
fn checked_mul(self, rhs: u32) -> Option<Self>;
fn checked_sub(self, rhs: Self) -> Option<Self>;
fn from_micros(micros: u64) -> Self;
fn from_millis(millis: u64) -> Self;
fn from_nanos(nanos: u64) -> Self;
fn from_secs(secs: u64) -> Self;
fn is_zero(&self) -> bool;
fn saturating_add(self, rhs: Self) -> Self;
fn saturating_mul(self, rhs: u32) -> Self;
fn saturating_sub(self, rhs: Self) -> Self;
fn subsec_micros(&self) -> u32;
fn subsec_millis(&self) -> u32;
fn subsec_nanos(&self) -> u32;
}
Expand description
A trait for time durations that follow the API of std::time::Duration
. This is useful for
code that should work with not just the real time, but also simulated time.
Required Associated Constants§
sourceconst NANOSECOND: Self
const NANOSECOND: Self
sourceconst MICROSECOND: Self
const MICROSECOND: Self
sourceconst MILLISECOND: Self
const MILLISECOND: Self
Required Methods§
sourcefn checked_add(self, rhs: Self) -> Option<Self>
fn checked_add(self, rhs: Self) -> Option<Self>
sourcefn checked_div(self, rhs: u32) -> Option<Self>
fn checked_div(self, rhs: u32) -> Option<Self>
sourcefn checked_mul(self, rhs: u32) -> Option<Self>
fn checked_mul(self, rhs: u32) -> Option<Self>
sourcefn checked_sub(self, rhs: Self) -> Option<Self>
fn checked_sub(self, rhs: Self) -> Option<Self>
sourcefn from_micros(micros: u64) -> Self
fn from_micros(micros: u64) -> Self
sourcefn from_millis(millis: u64) -> Self
fn from_millis(millis: u64) -> Self
sourcefn from_nanos(nanos: u64) -> Self
fn from_nanos(nanos: u64) -> Self
sourcefn saturating_add(self, rhs: Self) -> Self
fn saturating_add(self, rhs: Self) -> Self
sourcefn saturating_mul(self, rhs: u32) -> Self
fn saturating_mul(self, rhs: u32) -> Self
sourcefn saturating_sub(self, rhs: Self) -> Self
fn saturating_sub(self, rhs: Self) -> Self
sourcefn subsec_micros(&self) -> u32
fn subsec_micros(&self) -> u32
sourcefn subsec_millis(&self) -> u32
fn subsec_millis(&self) -> u32
sourcefn subsec_nanos(&self) -> u32
fn subsec_nanos(&self) -> u32
Object Safety§
This trait is not object safe.
Implementations on Foreign Types§
source§impl Duration for Duration
impl Duration for Duration
Calls into std::time::Duration
methods of the same name.