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
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl Duration for Duration
Calls into std::time::Duration methods of the same name.
 
impl Duration for Duration
Calls into std::time::Duration methods of the same name.