Struct embedded_time::rate::Generic[][src]

pub struct Generic<T> { /* fields omitted */ }
Expand description

The Generic Rate type allows an arbitrary scaling factor to be used without having to impl FixedPoint.

The purpose of this type is to allow a simple Rate object that can be defined at run-time. It does this by replacing the const scaling factor with a struct field.

Implementations

impl<T: TimeInt> Generic<T>[src]

pub fn new(integer: T, scaling_factor: Fraction) -> Self[src]

Constructs a new fixed-point Generic Rate value

pub fn integer(&self) -> T[src]

Returns the integer part

pub fn scaling_factor(&self) -> &Fraction[src]

Returns the scaling factor Fraction part

Trait Implementations

impl<T: Clone> Clone for Generic<T>[src]

fn clone(&self) -> Generic<T>[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<T: Debug> Debug for Generic<T>[src]

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

Formats the value using the given formatter. Read more

impl<T: Default> Default for Generic<T>[src]

fn default() -> Generic<T>[src]

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

impl<T: Hash> Hash for Generic<T>[src]

fn hash<__H: Hasher>(&self, state: &mut __H)[src]

Feeds this value into the given Hasher. Read more

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

Feeds a slice of this type into the given Hasher. Read more

impl<T: Ord> Ord for Generic<T>[src]

fn cmp(&self, other: &Generic<T>) -> Ordering[src]

This method returns an Ordering between self and other. Read more

#[must_use]
fn max(self, other: Self) -> Self
1.21.0[src]

Compares and returns the maximum of two values. Read more

#[must_use]
fn min(self, other: Self) -> Self
1.21.0[src]

Compares and returns the minimum of two values. Read more

#[must_use]
fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]

Restrict a value to a certain interval. Read more

impl<T: PartialEq> PartialEq<Generic<T>> for Generic<T>[src]

fn eq(&self, other: &Generic<T>) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &Generic<T>) -> bool[src]

This method tests for !=.

impl<T: PartialOrd> PartialOrd<Generic<T>> for Generic<T>[src]

fn partial_cmp(&self, other: &Generic<T>) -> Option<Ordering>[src]

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

#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests less than (for self and other) and is used by the < operator. Read more

#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]

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

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

fn to_generic<DestInt: TimeInt>(
    self,
    scaling_factor: Fraction
) -> Result<Generic<DestInt>, ConversionError> where
    Self: FixedPoint,
    DestInt: TryFrom<Self::T>, 
[src]

Construct a Generic Rate from a named Rate (eg. Kilohertz) Read more

fn to_duration<Duration: Duration>(&self) -> Result<Duration, ConversionError> where
    Duration: FixedPoint,
    Self: FixedPoint,
    Duration::T: TryFrom<Self::T>, 
[src]

Convert to named Duration Read more

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

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

type Error = ConversionError

The type returned in the event of a conversion error.

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

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

type Error = ConversionError

The type returned in the event of a conversion error.

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

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

type Error = ConversionError

The type returned in the event of a conversion error.

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

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

type Error = ConversionError

The type returned in the event of a conversion error.

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

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

type Error = ConversionError

The type returned in the event of a conversion error.

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

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

type Error = ConversionError

The type returned in the event of a conversion error.

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

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

type Error = ConversionError

The type returned in the event of a conversion error.

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

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

type Error = ConversionError

The type returned in the event of a conversion error.

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

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

type Error = ConversionError

The type returned in the event of a conversion error.

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

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

type Error = ConversionError

The type returned in the event of a conversion error.

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

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

type Error = ConversionError

The type returned in the event of a conversion error.

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

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

type Error = ConversionError

The type returned in the event of a conversion error.

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

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

type Error = ConversionError

The type returned in the event of a conversion error.

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

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

type Error = ConversionError

The type returned in the event of a conversion error.

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

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

type Error = ConversionError

The type returned in the event of a conversion error.

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

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

type Error = ConversionError

The type returned in the event of a conversion error.

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

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

type Error = ConversionError

The type returned in the event of a conversion error.

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

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

type Error = ConversionError

The type returned in the event of a conversion error.

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

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

type Error = ConversionError

The type returned in the event of a conversion error.

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

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

type Error = ConversionError

The type returned in the event of a conversion error.

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

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

type Error = ConversionError

The type returned in the event of a conversion error.

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

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

type Error = ConversionError

The type returned in the event of a conversion error.

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

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

type Error = ConversionError

The type returned in the event of a conversion error.

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

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

type Error = ConversionError

The type returned in the event of a conversion error.

impl<T: Copy> Copy for Generic<T>[src]

impl<T: Eq> Eq for Generic<T>[src]

impl<T> StructuralEq for Generic<T>[src]

impl<T> StructuralPartialEq for Generic<T>[src]

Auto Trait Implementations

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

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

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

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

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.

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

Performs the conversion.

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.

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

Performs the conversion.