[][src]Struct embedded_time::units::Hertz

pub struct Hertz<T: TimeInt = u32>(pub T);

A frequency unit type

Convertible to/from Period.

Trait Implementations

impl<T: Debug + TimeInt> Debug for Hertz<T>[src]

impl<T: TimeInt, Rhs: TimeInt> Div<Rhs> for Hertz<T> where
    T: From<Rhs>, 
[src]

type Output = Self

The resulting type after applying the / operator.

fn div(self, rhs: Rhs) -> Self::Output[src]

assert_eq!(Hertz(300_u32) / 3_u32, Hertz(100_u32));

impl<T: Eq + TimeInt> Eq for Hertz<T>[src]

impl From<Hertz<u32>> for u32[src]

fn from(hertz: Hertz) -> Self[src]

assert_eq!(u32::from(Hertz(23)), 23_u32);
assert_eq!(<u32 as Into<Hertz>>::into(23), Hertz(23_u32));

impl From<u32> for Hertz[src]

fn from(value: u32) -> Self[src]

assert_eq!(Hertz::from(23), Hertz(23_u32));
assert_eq!(<Hertz as Into<u32>>::into(Hertz(23_u32)), 23_u32);

impl<T: TimeInt, Rhs: TimeInt> Mul<Rhs> for Hertz<T> where
    T: From<Rhs>, 
[src]

type Output = Self

The resulting type after applying the * operator.

fn mul(self, rhs: Rhs) -> Self::Output[src]

assert_eq!(Hertz(100_u32) * 3_u32, Hertz(300_u32));

impl<T: Ord + TimeInt> Ord for Hertz<T>[src]

impl<T: PartialEq + TimeInt> PartialEq<Hertz<T>> for Hertz<T>[src]

impl<T: PartialOrd + TimeInt> PartialOrd<Hertz<T>> for Hertz<T>[src]

impl<T: TimeInt> StructuralEq for Hertz<T>[src]

impl<T: TimeInt> StructuralPartialEq for Hertz<T>[src]

impl<T: TimeInt> TryFrom<Hertz<T>> for Period<T>[src]

type Error = ConversionError

The type returned in the event of a conversion error.

fn try_from(freq: Hertz<T>) -> Result<Self, Self::Error>[src]

Constructs a Period in seconds from a frequency in Hertz

Examples

assert_eq!(Period::try_from(Hertz(1_000_u32)),
    Ok(<Period>::new(1, 1_000)));

assert_eq!(Period::try_from(Hertz(0_u32)),
    Err(ConversionError::DivByZero));

assert_eq!(Hertz(1_000_u32).try_into(),
    Ok(<Period>::new(1, 1_000)));

Errors

ConversionError::DivByZero

impl<T: TimeInt> TryFrom<Period<T>> for Hertz<T>[src]

type Error = ConversionError

The type returned in the event of a conversion error.

fn try_from(period: Period<T>) -> Result<Self, Self::Error>[src]

Create a new Frequency from a fractional Period in seconds

Examples

assert_eq!(Hertz::try_from(<Period>::new(1, 1_000)),
    Ok(Hertz(1_000_u32)));

assert_eq!(Hertz::try_from(<Period>::new(0, 1_000)),
    Err(ConversionError::DivByZero));

assert_eq!(<Period>::new(1, 1_000).try_into(),
    Ok(Hertz(1_000_u32)));

Errors

ConversionError::DivByZero

Auto Trait Implementations

impl<T> RefUnwindSafe for Hertz<T> where
    T: RefUnwindSafe

impl<T> Send for Hertz<T> where
    T: Send

impl<T> Sync for Hertz<T> where
    T: Sync

impl<T> Unpin for Hertz<T> where
    T: Unpin

impl<T> UnwindSafe for Hertz<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.