[−][src]Struct embedded_time::rate::Generic
The Generic Rate type allows arbitrary _scaling factor_s to be used without having to impl
FixedPoint.
The purpose of this type is to allow a simple Rate that can be defined at run-time. It does
this by replacing the const scaling factor with a field.
Implementations
impl<T> Generic<T>[src]
pub const fn new(integer: T, scaling_factor: Fraction) -> Self[src]
Constructs a new (ram) fixed-point Generic Rate value
pub const fn integer(&self) -> &T[src]
Returns the integer value
pub const fn scaling_factor(&self) -> &Fraction[src]
Returns the scaling factor Fraction value
Trait Implementations
impl<T: Clone> Clone for Generic<T>[src]
impl<T: Copy> Copy for Generic<T>[src]
impl<T: Debug> Debug for Generic<T>[src]
impl<T: Eq> Eq for Generic<T>[src]
impl<T: TimeInt> From<Baud<T>> for Generic<T>[src]
impl<T: TimeInt> From<BitsPerSecond<T>> for Generic<T>[src]
fn from(rate: BitsPerSecond<T>) -> Self[src]
impl<T: TimeInt> From<BytesPerSecond<T>> for Generic<T>[src]
fn from(rate: BytesPerSecond<T>) -> Self[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]
fn from(rate: KibibitsPerSecond<T>) -> Self[src]
impl<T: TimeInt> From<KibibytesPerSecond<T>> for Generic<T>[src]
fn from(rate: KibibytesPerSecond<T>) -> Self[src]
impl<T: TimeInt> From<KiloBytesPerSecond<T>> for Generic<T>[src]
fn from(rate: KiloBytesPerSecond<T>) -> Self[src]
impl<T: TimeInt> From<Kilobaud<T>> for Generic<T>[src]
impl<T: TimeInt> From<KilobitsPerSecond<T>> for Generic<T>[src]
fn from(rate: KilobitsPerSecond<T>) -> Self[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]
fn from(rate: MebibitsPerSecond<T>) -> Self[src]
impl<T: TimeInt> From<MebibytesPerSecond<T>> for Generic<T>[src]
fn from(rate: MebibytesPerSecond<T>) -> Self[src]
impl<T: TimeInt> From<Megabaud<T>> for Generic<T>[src]
impl<T: TimeInt> From<MegabitsPerSecond<T>> for Generic<T>[src]
fn from(rate: MegabitsPerSecond<T>) -> Self[src]
impl<T: TimeInt> From<MegabytesPerSecond<T>> for Generic<T>[src]
fn from(rate: MegabytesPerSecond<T>) -> Self[src]
impl<T: TimeInt> From<Megahertz<T>> for Generic<T>[src]
impl<T: PartialEq> PartialEq<Generic<T>> for Generic<T>[src]
impl<T: TimeInt> Rate for Generic<T>[src]
fn try_into_generic<DestInt: TimeInt>(
self,
scaling_factor: Fraction
) -> Result<Generic<DestInt>, ConversionError> where
Self: FixedPoint,
DestInt: TryFrom<Self::T>, [src]
self,
scaling_factor: Fraction
) -> Result<Generic<DestInt>, ConversionError> where
Self: FixedPoint,
DestInt: TryFrom<Self::T>,
fn try_from_duration<Duration: Duration>(
duration: Duration
) -> Result<Self, ConversionError> where
Duration: FixedPoint,
Self: FixedPoint,
Self::T: TryFrom<Duration::T>, [src]
duration: Duration
) -> Result<Self, ConversionError> where
Duration: FixedPoint,
Self: FixedPoint,
Self::T: TryFrom<Duration::T>,
impl<T> StructuralEq for Generic<T>[src]
impl<T> StructuralPartialEq for Generic<T>[src]
impl<SourceInt: TimeInt, DestInt: TimeInt> TryFrom<Generic<SourceInt>> for Megahertz<DestInt> where
DestInt: TryFrom<SourceInt>, [src]
DestInt: TryFrom<SourceInt>,
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));
impl<SourceInt: TimeInt, DestInt: TimeInt> TryFrom<Generic<SourceInt>> for Kilohertz<DestInt> where
DestInt: TryFrom<SourceInt>, [src]
DestInt: TryFrom<SourceInt>,
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));
impl<SourceInt: TimeInt, DestInt: TimeInt> TryFrom<Generic<SourceInt>> for KibibitsPerSecond<DestInt> where
DestInt: TryFrom<SourceInt>, [src]
DestInt: TryFrom<SourceInt>,
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));
impl<SourceInt: TimeInt, DestInt: TimeInt> TryFrom<Generic<SourceInt>> for KilobitsPerSecond<DestInt> where
DestInt: TryFrom<SourceInt>, [src]
DestInt: TryFrom<SourceInt>,
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));
impl<SourceInt: TimeInt, DestInt: TimeInt> TryFrom<Generic<SourceInt>> for BitsPerSecond<DestInt> where
DestInt: TryFrom<SourceInt>, [src]
DestInt: TryFrom<SourceInt>,
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));
impl<SourceInt: TimeInt, DestInt: TimeInt> TryFrom<Generic<SourceInt>> for Mebibaud<DestInt> where
DestInt: TryFrom<SourceInt>, [src]
DestInt: TryFrom<SourceInt>,
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));
impl<SourceInt: TimeInt, DestInt: TimeInt> TryFrom<Generic<SourceInt>> for Megabaud<DestInt> where
DestInt: TryFrom<SourceInt>, [src]
DestInt: TryFrom<SourceInt>,
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));
impl<SourceInt: TimeInt, DestInt: TimeInt> TryFrom<Generic<SourceInt>> for Kibibaud<DestInt> where
DestInt: TryFrom<SourceInt>, [src]
DestInt: TryFrom<SourceInt>,
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));
impl<SourceInt: TimeInt, DestInt: TimeInt> TryFrom<Generic<SourceInt>> for Kilobaud<DestInt> where
DestInt: TryFrom<SourceInt>, [src]
DestInt: TryFrom<SourceInt>,
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));
impl<SourceInt: TimeInt, DestInt: TimeInt> TryFrom<Generic<SourceInt>> for Baud<DestInt> where
DestInt: TryFrom<SourceInt>, [src]
DestInt: TryFrom<SourceInt>,
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));
impl<SourceInt: TimeInt, DestInt: TimeInt> TryFrom<Generic<SourceInt>> for Hertz<DestInt> where
DestInt: TryFrom<SourceInt>, [src]
DestInt: TryFrom<SourceInt>,
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));
impl<SourceInt: TimeInt, DestInt: TimeInt> TryFrom<Generic<SourceInt>> for MebibytesPerSecond<DestInt> where
DestInt: TryFrom<SourceInt>, [src]
DestInt: TryFrom<SourceInt>,
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));
impl<SourceInt: TimeInt, DestInt: TimeInt> TryFrom<Generic<SourceInt>> for MegabytesPerSecond<DestInt> where
DestInt: TryFrom<SourceInt>, [src]
DestInt: TryFrom<SourceInt>,
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));
impl<SourceInt: TimeInt, DestInt: TimeInt> TryFrom<Generic<SourceInt>> for KibibytesPerSecond<DestInt> where
DestInt: TryFrom<SourceInt>, [src]
DestInt: TryFrom<SourceInt>,
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));
impl<SourceInt: TimeInt, DestInt: TimeInt> TryFrom<Generic<SourceInt>> for KiloBytesPerSecond<DestInt> where
DestInt: TryFrom<SourceInt>, [src]
DestInt: TryFrom<SourceInt>,
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));
impl<SourceInt: TimeInt, DestInt: TimeInt> TryFrom<Generic<SourceInt>> for BytesPerSecond<DestInt> where
DestInt: TryFrom<SourceInt>, [src]
DestInt: TryFrom<SourceInt>,
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));
impl<SourceInt: TimeInt, DestInt: TimeInt> TryFrom<Generic<SourceInt>> for MebibitsPerSecond<DestInt> where
DestInt: TryFrom<SourceInt>, [src]
DestInt: TryFrom<SourceInt>,
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));
impl<SourceInt: TimeInt, DestInt: TimeInt> TryFrom<Generic<SourceInt>> for MegabitsPerSecond<DestInt> where
DestInt: TryFrom<SourceInt>, [src]
DestInt: TryFrom<SourceInt>,
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 Generic<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Generic<T> where
T: Send,
T: Send,
impl<T> Sync for Generic<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Generic<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Generic<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T[src]
fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,