[−][src]Struct embedded_time::units::Seconds
A duration unit type
Trait Implementations
impl<Rep, RhsDur> Add<RhsDur> for Seconds<Rep> where
RhsDur: Duration,
RhsDur::Rep: TimeInt,
Rep: TimeInt + TryFrom<RhsDur::Rep>,
[src]
RhsDur: Duration,
RhsDur::Rep: TimeInt,
Rep: TimeInt + TryFrom<RhsDur::Rep>,
type Output = Self
The resulting type after applying the +
operator.
fn add(self, rhs: RhsDur) -> Self::Output
[src]
See module-level documentation for details about this type
impl<T: Clone + TimeInt> Clone for Seconds<T>
[src]
impl<T: Copy + TimeInt> Copy for Seconds<T>
[src]
impl<T: Debug + TimeInt> Debug for Seconds<T>
[src]
impl<T: TimeInt> Display for Seconds<T>
[src]
fn fmt(&self, f: &mut Formatter) -> Result
[src]
See module-level documentation for details about this type
impl<Rep: TimeInt> Duration for Seconds<Rep>
[src]
type Rep = Rep
The inner type of the Duration
representing the count of the implementation unit
const PERIOD: Period
[src]
fn new(value: Self::Rep) -> Self
[src]
fn count(self) -> Self::Rep
[src]
fn from_ticks<Rep: TimeInt>(
ticks: Rep,
period: Period
) -> Result<Self, ConversionError> where
Self::Rep: TryFrom<Rep>,
[src]
ticks: Rep,
period: Period
) -> Result<Self, ConversionError> where
Self::Rep: TryFrom<Rep>,
fn into_ticks<Rep: TimeInt>(
self,
period: Period
) -> Result<Rep, ConversionError> where
Self::Rep: TimeInt,
Rep: TryFrom<Self::Rep>,
[src]
self,
period: Period
) -> Result<Rep, ConversionError> where
Self::Rep: TimeInt,
Rep: TryFrom<Self::Rep>,
#[must_use]fn min_value() -> Self::Rep
[src]
#[must_use]fn max_value() -> Self::Rep
[src]
impl<T: Eq + TimeInt> Eq for Seconds<T>
[src]
impl<T: Ord + TimeInt> Ord for Seconds<T>
[src]
fn cmp(&self, other: &Seconds<T>) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<Rep, OtherDur> PartialEq<OtherDur> for Seconds<Rep> where
Rep: TimeInt + TryFrom<OtherDur::Rep>,
OtherDur: Duration,
OtherDur::Rep: TryFrom<Rep>,
[src]
Rep: TimeInt + TryFrom<OtherDur::Rep>,
OtherDur: Duration,
OtherDur::Rep: TryFrom<Rep>,
fn eq(&self, other: &OtherDur) -> bool
[src]
See module-level documentation for details about this type
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<Rep, OtherDur> PartialOrd<OtherDur> for Seconds<Rep> where
Rep: TimeInt + TryFrom<OtherDur::Rep>,
OtherDur: Duration,
OtherDur::Rep: TryFrom<Rep>,
[src]
Rep: TimeInt + TryFrom<OtherDur::Rep>,
OtherDur: Duration,
OtherDur::Rep: TryFrom<Rep>,
fn partial_cmp(&self, other: &OtherDur) -> Option<Ordering>
[src]
See module-level documentation for details about this type
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<Rep, Dur> Rem<Dur> for Seconds<Rep> where
Rep: TimeInt + TryFrom<Dur::Rep>,
Dur: Duration,
[src]
Rep: TimeInt + TryFrom<Dur::Rep>,
Dur: Duration,
type Output = Self
The resulting type after applying the %
operator.
fn rem(self, rhs: Dur) -> Self::Output
[src]
impl<T: TimeInt> StructuralEq for Seconds<T>
[src]
impl<Rep, RhsDur> Sub<RhsDur> for Seconds<Rep> where
Rep: TimeInt + TryFrom<RhsDur::Rep>,
RhsDur: Duration,
[src]
Rep: TimeInt + TryFrom<RhsDur::Rep>,
RhsDur: Duration,
type Output = Self
The resulting type after applying the -
operator.
fn sub(self, rhs: RhsDur) -> Self::Output
[src]
See module-level documentation for details about this type
impl<Rep: TimeInt> TryFrom<Duration> for Seconds<Rep>
[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]
Convert a core::time::Duration
into an embedded_time::Duration
impl<Rep: TimeInt> TryFrom<Seconds<Rep>> for Duration
[src]
type Error = ConversionError
The type returned in the event of a conversion error.
fn try_from(duration: Seconds<Rep>) -> Result<Self, Self::Error>
[src]
Convert an embedded_time::Duration
into a core::time::Duration
Auto Trait Implementations
impl<T> RefUnwindSafe for Seconds<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Seconds<T> where
T: Send,
T: Send,
impl<T> Sync for Seconds<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Seconds<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Seconds<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<Source, Dest> TryConvertFrom<Source> for Dest where
Dest: Duration,
Source: Duration,
<Dest as Duration>::Rep: TryFrom<<Source as Duration>::Rep>,
[src]
Dest: Duration,
Source: Duration,
<Dest as Duration>::Rep: TryFrom<<Source as Duration>::Rep>,
fn try_convert_from(Source) -> Result<Dest, ConversionError>
[src]
Attempt to convert from one duration type to another
Both the inner type and/or the LSbit period (units) can be converted
Examples
assert_eq!(Seconds::<u32>::try_convert_from(Milliseconds(23_000_u64)), Ok(Seconds(23_u32))); assert_eq!(Seconds::<u64>::try_convert_from(Milliseconds(23_000_u32)), Ok(Seconds(23_u64))); assert_eq!(Seconds::<u32>::try_convert_from(Milliseconds(230_u32)), Ok(Seconds(0)));
Errors
Failure will only occur if the value does not fit in the selected destination type.
ConversionError::Overflow
: The conversion of periods causes an overflow:
assert_eq!(Milliseconds::<u32>::try_convert_from(Seconds(u32::MAX)), Err(ConversionError::Overflow));
ConversionError::ConversionFailure
: The Self integer cast to that of the destination
type fails:
assert_eq!(Seconds::<u32>::try_convert_from(Seconds(u32::MAX as u64 + 1)), Err(ConversionError::ConversionFailure));
However, these work because the sequence of cast/conversion adapts:
// period conversion applied first assert_eq!(Hours::<u32>::try_convert_from(Microseconds(3_600_000_000_u64)), Ok(Hours(1_u32))); // cast applied first assert_eq!(Microseconds::<u64>::try_convert_from(Hours(1_u32)), Ok(Microseconds(3_600_000_000_u64)));
impl<Source, Dest> TryConvertInto<Dest> for Source where
Dest: Duration + TryConvertFrom<Source>,
Source: Duration,
[src]
Dest: Duration + TryConvertFrom<Source>,
Source: Duration,
fn try_convert_into(Self) -> Result<Dest, ConversionError>
[src]
The reciprocal of TryConvertFrom
Examples
assert_eq!(Seconds(23_u64).try_convert_into(), Ok(Seconds(23_u32))); assert_eq!(Seconds(23_u32).try_convert_into(), Ok(Seconds(23_u64))); assert_eq!(Milliseconds(23_000_u64).try_convert_into(), Ok(Seconds(23_u32)));
Errors
Failure will only occur if the value does not fit in the selected destination type.
ConversionError::Overflow
- The conversion of periods causes an overflow:
use embedded_time::duration::TryConvertInto; assert_eq!(<Seconds<u32> as TryConvertInto<Milliseconds<u32>>>::try_convert_into(Seconds(u32::MAX)), Err(ConversionError::Overflow));
ConversionError::ConversionFailure
- The Self integer cast to that of the destination
type fails:
use embedded_time::duration::TryConvertInto; assert_eq!(<Seconds<u64> as TryConvertInto<Seconds<u32>>>::try_convert_into(Seconds(u32::MAX as u64 + 1)), Err(ConversionError::ConversionFailure));
However, the following work because the sequence of cast/conversion adapts:
// period conversion applied first assert_eq!(Microseconds(3_600_000_000_u64).try_convert_into(), Ok(Hours(1_u32))); // cast applied first assert_eq!(Hours(1_u32).try_convert_into(), Ok(Microseconds(3_600_000_000_u64)));
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>,