[][src]Trait embedded_time::TimeRep

pub trait TimeRep: PrimInt + WrappingAdd + WrappingSub + From<i32> + TryInto<i32> + TryFrom<i64> + Into<i64> + Display + Debug {
    fn nanoseconds(self) -> Nanoseconds<Self>;
fn microseconds(self) -> Microseconds<Self>;
fn milliseconds(self) -> Milliseconds<Self>;
fn seconds(self) -> Seconds<Self>;
fn minutes(self) -> Minutes<Self>;
fn hours(self) -> Hours<Self>; fn checked_mul(&self, ratio: &Period) -> Option<Self> { ... }
fn checked_div(&self, ratio: &Period) -> Option<Self> { ... } }

Create Durations from primitive and core numeric types.

This trait can be imported with use embedded-time::prelude::*.

Examples

Basic construction of Durations.

assert_eq!(5.nanoseconds(), Nanoseconds(5));
assert_eq!(5.microseconds(), Microseconds(5));
assert_eq!(5.milliseconds(), Milliseconds(5));
assert_eq!(5.seconds(), Seconds(5));
assert_eq!(5.minutes(), Minutes(5));
assert_eq!(5.hours(), Hours(5));

Signed integers work as well!

assert_eq!((-5).nanoseconds(), Nanoseconds(-5));
assert_eq!((-5).microseconds(), Microseconds(-5));
assert_eq!((-5).milliseconds(), Milliseconds(-5));
assert_eq!((-5).seconds(), Seconds(-5));
assert_eq!((-5).minutes(), Minutes(-5));
assert_eq!((-5).hours(), Hours(-5));

Required methods

fn nanoseconds(self) -> Nanoseconds<Self>

fn microseconds(self) -> Microseconds<Self>

fn milliseconds(self) -> Milliseconds<Self>

fn seconds(self) -> Seconds<Self>

fn minutes(self) -> Minutes<Self>

fn hours(self) -> Hours<Self>

Loading content...

Provided methods

fn checked_mul(&self, ratio: &Period) -> Option<Self>

fn checked_div(&self, ratio: &Period) -> Option<Self>

Loading content...

Implementors

impl TimeRep for i32[src]

Create a duration from a primitive integer type

impl TimeRep for i64[src]

Create a duration from a primitive integer type

Loading content...