ariel_os::time

Struct Duration

pub struct Duration { /* private fields */ }
Available on crate feature time only.
Expand description

Represents the difference between two Instants

Implementations§

§

impl Duration

pub const MIN: Duration = _

The smallest value that can be represented by the Duration type.

pub const MAX: Duration = _

The largest value that can be represented by the Duration type.

pub const fn as_ticks(&self) -> u64

Tick count of the Duration.

pub const fn as_secs(&self) -> u64

Convert the Duration to seconds, rounding down.

pub const fn as_millis(&self) -> u64

Convert the Duration to milliseconds, rounding down.

pub const fn as_micros(&self) -> u64

Convert the Duration to microseconds, rounding down.

pub const fn from_ticks(ticks: u64) -> Duration

Creates a duration from the specified number of clock ticks

pub const fn from_secs(secs: u64) -> Duration

Creates a duration from the specified number of seconds, rounding up.

pub const fn from_millis(millis: u64) -> Duration

Creates a duration from the specified number of milliseconds, rounding up.

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.

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.

pub const fn from_secs_floor(secs: u64) -> Duration

Creates a duration from the specified number of seconds, rounding down.

pub const fn from_millis_floor(millis: u64) -> Duration

Creates a duration from the specified number of milliseconds, rounding down.

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.

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.

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.

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.

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.

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§

§

impl Add<Duration> for Instant

§

type Output = Instant

The resulting type after applying the + operator.
§

fn add(self, other: Duration) -> Instant

Performs the + operation. Read more
§

impl Add for Duration

§

type Output = Duration

The resulting type after applying the + operator.
§

fn add(self, rhs: Duration) -> Duration

Performs the + operation. Read more
§

impl AddAssign<Duration> for Instant

§

fn add_assign(&mut self, other: Duration)

Performs the += operation. Read more
§

impl AddAssign for Duration

§

fn add_assign(&mut self, rhs: Duration)

Performs the += operation. Read more
§

impl Clone for Duration

§

fn clone(&self) -> Duration

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for Duration

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl Default for Duration

§

fn default() -> Duration

Returns the “default value” for a type. Read more
§

impl<'a> Display for Duration

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl Div<u32> for Duration

§

type Output = Duration

The resulting type after applying the / operator.
§

fn div(self, rhs: u32) -> Duration

Performs the / operation. Read more
§

impl DivAssign<u32> for Duration

§

fn div_assign(&mut self, rhs: u32)

Performs the /= operation. Read more
§

impl Format for Duration

§

fn format(&self, f: Formatter<'_>)

Writes the defmt representation of self to fmt.
§

impl Mul<u32> for Duration

§

type Output = Duration

The resulting type after applying the * operator.
§

fn mul(self, rhs: u32) -> Duration

Performs the * operation. Read more
§

impl MulAssign<u32> for Duration

§

fn mul_assign(&mut self, rhs: u32)

Performs the *= operation. Read more
§

impl Ord for Duration

§

fn cmp(&self, other: &Duration) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
§

impl PartialEq for Duration

§

fn eq(&self, other: &Duration) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl PartialOrd for Duration

§

fn partial_cmp(&self, other: &Duration) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
§

impl Sub<Duration> for Instant

§

type Output = Instant

The resulting type after applying the - operator.
§

fn sub(self, other: Duration) -> Instant

Performs the - operation. Read more
§

impl Sub for Duration

§

type Output = Duration

The resulting type after applying the - operator.
§

fn sub(self, rhs: Duration) -> Duration

Performs the - operation. Read more
§

impl SubAssign<Duration> for Instant

§

fn sub_assign(&mut self, other: Duration)

Performs the -= operation. Read more
§

impl SubAssign for Duration

§

fn sub_assign(&mut self, rhs: Duration)

Performs the -= operation. Read more
§

impl TryFrom<Duration> for Duration

§

fn try_from( value: Duration, ) -> Result<Duration, <Duration as TryFrom<Duration>>::Error>

Converts using Duration::from_micros. Fails if value can not be represented as u64.

§

type Error = <u64 as TryFrom<u128>>::Error

The type returned in the event of a conversion error.
§

impl Copy for Duration

§

impl Eq for Duration

§

impl StructuralPartialEq for Duration

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

§

const WITNESS: W = W::MAKE

A constant of the type witness
§

impl<T> Identity for T
where T: ?Sized,

§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> FormatOrDebug for T
where T: Format,

§

impl<T, Rhs, Output> GroupOps<Rhs, Output> for T
where T: Add<Rhs, Output = Output> + Sub<Rhs, Output = Output> + AddAssign<Rhs> + SubAssign<Rhs>,

§

impl<T, Rhs, Output> ScalarMul<Rhs, Output> for T
where T: Mul<Rhs, Output = Output> + MulAssign<Rhs>,