[−][src]Struct embedded_time::duration::units::Hours
A duration unit type
Trait Implementations
impl<T: TimeInt, Rhs: Duration> Add<Rhs> for Hours<T> where
Rhs: FixedPoint,
T: TryFrom<Rhs::T>, [src]
Rhs: FixedPoint,
T: TryFrom<Rhs::T>,
type Output = Self
The resulting type after applying the + operator.
fn add(self, rhs: Rhs) -> Self::Output[src]
impl<T: Clone + TimeInt> Clone for Hours<T>[src]
impl<T: Copy + TimeInt> Copy for Hours<T>[src]
impl<T: Debug + TimeInt> Debug for Hours<T>[src]
impl<T: TimeInt> Display for Hours<T>[src]
fn fmt(&self, f: &mut Formatter) -> Result[src]
Just forwards the underlying integer to core::fmt::Display::fmt()
assert_eq!(format!("{}", Seconds(123_u32)), "123");
impl<T: TimeInt> Duration for Hours<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_rate<Rate: Rate>(rate: Rate) -> Result<Self, ConversionError> where
Rate: FixedPoint,
Self: FixedPoint,
Self::T: TryFrom<Rate::T>, [src]
Rate: FixedPoint,
Self: FixedPoint,
Self::T: TryFrom<Rate::T>,
impl<T: Eq + TimeInt> Eq for Hours<T>[src]
impl<T: Ord + TimeInt> Ord for Hours<T>[src]
fn cmp(&self, other: &Hours<T>) -> Ordering[src]
#[must_use]fn max(self, other: Self) -> Self1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self[src]
impl<T: TimeInt, Rhs: Duration> PartialEq<Rhs> for Hours<T> where
T: TryFrom<Rhs::T>,
Rhs: FixedPoint,
Rhs::T: TryFrom<T>, [src]
T: TryFrom<Rhs::T>,
Rhs: FixedPoint,
Rhs::T: TryFrom<T>,
fn eq(&self, rhs: &Rhs) -> bool[src]
assert_eq!(Seconds(123_u32), Milliseconds(123_000_u64)); assert_ne!(Seconds(123_u32), Milliseconds(123_001_u64));
#[must_use]fn ne(&self, other: &Rhs) -> bool1.0.0[src]
impl<T: TimeInt, Rhs: Duration> PartialOrd<Rhs> for Hours<T> where
T: TryFrom<Rhs::T>,
Rhs: FixedPoint,
Rhs::T: TryFrom<T>, [src]
T: TryFrom<Rhs::T>,
Rhs: FixedPoint,
Rhs::T: TryFrom<T>,
fn partial_cmp(&self, rhs: &Rhs) -> Option<Ordering>[src]
assert!(Seconds(2_u64) < Milliseconds(2_001_u32)); assert!(Seconds(2_u32) > Milliseconds(1_999_u32));
#[must_use]fn lt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool1.0.0[src]
impl<T: TimeInt, Rhs: Duration> Rem<Rhs> for Hours<T> where
T: TryFrom<Rhs::T>,
Rhs: FixedPoint, [src]
T: TryFrom<Rhs::T>,
Rhs: FixedPoint,
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!(Minutes(62_u32) % Hours(1_u32), Minutes(2_u32));
impl<T: TimeInt> StructuralEq for Hours<T>[src]
impl<T: TimeInt, Rhs: Duration> Sub<Rhs> for Hours<T> where
T: TryFrom<Rhs::T>,
Rhs: FixedPoint, [src]
T: TryFrom<Rhs::T>,
Rhs: FixedPoint,
type Output = Self
The resulting type after applying the - operator.
fn sub(self, rhs: Rhs) -> Self::Output[src]
impl<T: TimeInt> TryFrom<Duration> for Hours<T>[src]
type Error = ConversionError
The type returned in the event of a conversion error.
fn try_from(core_duration: Duration) -> Result<Self, Self::Error>[src]
Construct an embedded_time::Duration from a core::time::Duration
Examples
let core_duration = core::time::Duration::new(5, 730023852); assert_eq!(Milliseconds::<u32>::try_from(core_duration), Ok(5_730.milliseconds()));
let duration: Result<Milliseconds<u32>, _> = core::time::Duration::new(5, 730023852).try_into(); assert_eq!(duration, Ok(5_730.milliseconds()));
Errors
ConversionError::ConversionFailure : The result doesn't fit in the specified
type
assert_eq!( Milliseconds::<u32>::try_from(core::time::Duration::from_millis((u32::MAX as u64) + 1)), Err(ConversionError::ConversionFailure) ); let duration: Result<Milliseconds<u32>, _> = core::time::Duration::from_millis((u32::MAX as u64) + 1).try_into(); assert_eq!(duration, Err(ConversionError::ConversionFailure));
impl<SourceInt: TimeInt, DestInt: TimeInt> TryFrom<Generic<SourceInt>> for Hours<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_duration: Generic<SourceInt>) -> Result<Self, Self::Error>[src]
Construct a named Duration from a Generic Duration
Examples
assert_eq!( Seconds::<u64>::try_from(Generic::new(2_000_u32, Fraction::new(1, 1_000))), Ok(Seconds(2_u64)) ); // TryInto also works assert_eq!( Generic::new(2_000_u64, Fraction::new(1, 1_000)).try_into(), Ok(Seconds(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!( Seconds::<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!( Seconds::<u32>::try_from(Generic::new(u32::MAX as u64 + 1, Fraction::new(1,1))), Err(ConversionError::ConversionFailure) );
impl<T: TimeInt> TryFrom<Hours<T>> for Duration[src]
type Error = ConversionError
The type returned in the event of a conversion error.
fn try_from(duration: Hours<T>) -> Result<Self, Self::Error>[src]
Construct a core::time::Duration from an embedded_time::Duration
let core_duration = core::time::Duration::try_from(2_569_u32.milliseconds()).unwrap(); assert_eq!(core_duration.as_secs(), 2); assert_eq!(core_duration.subsec_nanos(), 569_000_000);
let core_duration: core::time::Duration = 2_569_u32.milliseconds().try_into().unwrap(); assert_eq!(core_duration.as_secs(), 2); assert_eq!(core_duration.subsec_nanos(), 569_000_000);
Auto Trait Implementations
impl<T> RefUnwindSafe for Hours<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Hours<T> where
T: Send,
T: Send,
impl<T> Sync for Hours<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Hours<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Hours<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> ToString for T where
T: Display + ?Sized, [src]
T: Display + ?Sized,
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>,