[][src]Struct embedded_time::rate::units::BitsPerSecond

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

Bits/s

Trait Implementations

impl<T: TimeInt, Rhs: Rate> Add<Rhs> for BitsPerSecond<T> where
    T: TryFrom<Rhs::T>,
    Rhs: FixedPoint, 
[src]

type Output = Self

The resulting type after applying the + operator.

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

Returns the sum as the LHS type

Examples

assert_eq!((Hertz(1_u32) + Hertz(1_u32)), Hertz(2_u32));

Panics

The same reason the integer operation would panic. Namely, if the result overflows the type.

This example panics
let _ = Hertz(u32::MAX) + Hertz(1_u32);

impl<T: Clone + TimeInt> Clone for BitsPerSecond<T>[src]

impl<T: Copy + TimeInt> Copy for BitsPerSecond<T>[src]

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

impl<T: TimeInt> Display for BitsPerSecond<T>[src]

fn fmt(&self, f: &mut Formatter) -> Result[src]

Just forwards the underlying integer to core::fmt::Display::fmt()

assert_eq!(format!("{}", Hertz(123_u32)), "123");

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

impl<T: TimeInt> From<BitsPerSecond<T>> for Generic<T>[src]

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

impl<T: TimeInt, Rhs: Rate> PartialEq<Rhs> for BitsPerSecond<T> where
    T: TryFrom<Rhs::T>,
    Rhs: FixedPoint,
    Rhs::T: TryFrom<T>, 
[src]

fn eq(&self, rhs: &Rhs) -> bool[src]

assert_eq!(Hertz(123_000_u32), Kilohertz(123_u32));
assert_ne!(Hertz(123_001_u32), Kilohertz(123_u32));

impl<T: TimeInt, Rhs: Rate> PartialOrd<Rhs> for BitsPerSecond<T> where
    T: TryFrom<Rhs::T>,
    Rhs: FixedPoint,
    Rhs::T: TryFrom<T>, 
[src]

fn partial_cmp(&self, rhs: &Rhs) -> Option<Ordering>[src]

assert!(Hertz(2_001_u32) > Kilohertz(2_u32));
assert!(Hertz(1_999_u32) < Kilohertz(2_u32));

impl<T: TimeInt> Rate for BitsPerSecond<T>[src]

impl<T: TimeInt, Rhs: Rate> Rem<Rhs> for BitsPerSecond<T> where
    T: TryFrom<Rhs::T>,
    Rhs: FixedPoint, 
[src]

type Output = Self

The resulting type after applying the % operator.

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

Returns the remainder as the LHS type

assert_eq!(Hertz(2_037_u32) % Kilohertz(1_u32), Hertz(37_u32));

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

impl<T: TimeInt, Rhs: Rate> Sub<Rhs> for BitsPerSecond<T> where
    T: TryFrom<Rhs::T>,
    Rhs: FixedPoint, 
[src]

type Output = Self

The resulting type after applying the - operator.

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

Returns the difference as the LHS type

Examples

assert_eq!((Hertz(2u32) - Hertz(1_u32)),
    Hertz(1_u32));

Panics

The same reason the integer operation would panic. Namely, if the result overflows the type.

This example panics
let _ = Hertz(0_u32) - Hertz(1_u32);

impl<SourceInt: TimeInt, DestInt: TimeInt> TryFrom<Generic<SourceInt>> for BitsPerSecond<DestInt> where
    DestInt: TryFrom<SourceInt>, 
[src]

type Error = ConversionError

The type returned in the event of a conversion error.

fn try_from(generic_rate: Generic<SourceInt>) -> Result<Self, Self::Error>[src]

Construct a named Rate from a Generic Rate

Examples

assert_eq!(
    Hertz::<u64>::try_from(Generic::new(2_000_u32, Fraction::new(1,1_000))),
    Ok(Hertz(2_u64))
);

assert_eq!(
    Generic::new(2_000_u64, Fraction::new(1,1_000)).try_into(),
    Ok(Hertz(2_u64))
);

Errors

Failure will only occur if the provided value does not fit in the selected destination type.


ConversionError::Overflow : The conversion of the scaling factor causes an overflow.

assert_eq!(Hertz::<u32>::try_from(Generic::new(u32::MAX, Fraction::new(10,1))),
    Err(ConversionError::Overflow));

ConversionError::ConversionFailure : The integer conversion to that of the destination type fails.

assert_eq!(Hertz::<u32>::try_from(Generic::new(u32::MAX as u64 + 1, Fraction::new(1,1))),
    Err(ConversionError::ConversionFailure));

Auto Trait Implementations

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

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

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

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

impl<T> UnwindSafe for BitsPerSecond<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> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[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.