Struct embassy_time::Duration
source · 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 PartialEq for Duration
impl PartialEq for Duration
source§impl PartialOrd for Duration
impl PartialOrd for Duration
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§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