pub struct Duration { /* private fields */ }
Expand description
Represents the difference between two Instants
Implementations§
Source§impl Duration
impl Duration
Sourcepub const fn from_ticks(ticks: u64) -> Duration
pub const fn from_ticks(ticks: u64) -> Duration
Creates a duration from the specified number of clock ticks
Sourcepub const fn from_secs(secs: u64) -> Duration
pub const fn from_secs(secs: u64) -> Duration
Creates a duration from the specified number of seconds, rounding up.
Sourcepub const fn from_millis(millis: u64) -> Duration
pub const fn from_millis(millis: u64) -> Duration
Creates a duration from the specified number of milliseconds, rounding up.
Sourcepub const fn from_micros(micros: u64) -> Duration
pub const fn from_micros(micros: u64) -> Duration
Creates a duration from the specified number of microseconds, rounding up. NOTE: Delays this small may be inaccurate.
Sourcepub const fn from_nanos(micros: u64) -> Duration
pub const fn from_nanos(micros: u64) -> Duration
Creates a duration from the specified number of nanoseconds, rounding up. NOTE: Delays this small may be inaccurate.
Sourcepub const fn from_secs_floor(secs: u64) -> Duration
pub const fn from_secs_floor(secs: u64) -> Duration
Creates a duration from the specified number of seconds, rounding down.
Sourcepub const fn from_millis_floor(millis: u64) -> Duration
pub const fn from_millis_floor(millis: u64) -> Duration
Creates a duration from the specified number of milliseconds, rounding down.
Sourcepub const fn from_micros_floor(micros: u64) -> Duration
pub const fn from_micros_floor(micros: u64) -> Duration
Creates a duration from the specified number of microseconds, rounding down. NOTE: Delays this small may be inaccurate.
Sourcepub const fn from_hz(hz: u64) -> Duration
pub const fn from_hz(hz: u64) -> Duration
Creates a duration corresponding to the specified Hz. NOTE: Giving this function a hz >= the TICK_HZ of your platform will clamp the Duration to 1 tick. Doing so will not deadlock, but will certainly not produce the desired output.
Sourcepub fn checked_add(self, rhs: Duration) -> Option<Duration>
pub fn checked_add(self, rhs: Duration) -> Option<Duration>
Adds one Duration to another, returning a new Duration or None in the event of an overflow.
Sourcepub fn checked_sub(self, rhs: Duration) -> Option<Duration>
pub fn checked_sub(self, rhs: Duration) -> Option<Duration>
Subtracts one Duration to another, returning a new Duration or None in the event of an overflow.
Sourcepub fn checked_mul(self, rhs: u32) -> Option<Duration>
pub fn checked_mul(self, rhs: u32) -> Option<Duration>
Multiplies one Duration by a scalar u32, returning a new Duration or None in the event of an overflow.
Sourcepub fn checked_div(self, rhs: u32) -> Option<Duration>
pub fn checked_div(self, rhs: u32) -> Option<Duration>
Divides one Duration a scalar u32, returning a new Duration or None in the event of an overflow.
Trait Implementations§
Source§impl AddAssign<Duration> for Instant
impl AddAssign<Duration> for Instant
Source§fn add_assign(&mut self, other: Duration)
fn add_assign(&mut self, other: Duration)
+=
operation. Read moreSource§impl AddAssign for Duration
impl AddAssign for Duration
Source§fn add_assign(&mut self, rhs: Duration)
fn add_assign(&mut self, rhs: Duration)
+=
operation. Read moreSource§impl DivAssign<u32> for Duration
impl DivAssign<u32> for Duration
Source§fn div_assign(&mut self, rhs: u32)
fn div_assign(&mut self, rhs: u32)
/=
operation. Read moreSource§impl From<Duration> for Duration
impl From<Duration> for Duration
Source§fn from(value: Duration) -> Self
fn from(value: Duration) -> Self
Converts using Duration::as_micros
.
Source§impl MulAssign<u32> for Duration
impl MulAssign<u32> for Duration
Source§fn mul_assign(&mut self, rhs: u32)
fn mul_assign(&mut self, rhs: u32)
*=
operation. Read moreSource§impl Ord for Duration
impl Ord for Duration
Source§impl PartialOrd for Duration
impl PartialOrd for Duration
Source§impl SubAssign<Duration> for Instant
impl SubAssign<Duration> for Instant
Source§fn sub_assign(&mut self, other: Duration)
fn sub_assign(&mut self, other: Duration)
-=
operation. Read moreSource§impl SubAssign for Duration
impl SubAssign for Duration
Source§fn sub_assign(&mut self, rhs: Duration)
fn sub_assign(&mut self, rhs: Duration)
-=
operation. Read more