pub enum Unit {
Nanosecond,
Microsecond,
Millisecond,
Second,
Minute,
Hour,
Day,
Century,
}
Expand description
An Enum to perform time unit conversions.
Variants§
Nanosecond
Microsecond
Millisecond
Second
Minute
Hour
Day
Century
36525 days, is the number of days per century in the Julian calendar
Implementations§
source§impl Unit
impl Unit
pub fn in_seconds(&self) -> f64
pub fn from_seconds(&self) -> f64
Trait Implementations§
source§impl AddAssign<Unit> for Duration
impl AddAssign<Unit> for Duration
source§fn add_assign(&mut self, rhs: Unit)
fn add_assign(&mut self, rhs: Unit)
Performs the
+=
operation. Read moresource§impl AddAssign<Unit> for Epoch
impl AddAssign<Unit> for Epoch
source§fn add_assign(&mut self, unit: Unit)
fn add_assign(&mut self, unit: Unit)
Performs the
+=
operation. Read moresource§impl From<Unit> for u8
impl From<Unit> for u8
Allows conversion of a Unit into a u8 with the following mapping. 0: Second; 1: Nanosecond; 2: Microsecond; 3: Millisecond; 4: Minute; 5: Hour; 6: Day; 7: Century
source§impl From<u8> for Unit
impl From<u8> for Unit
Allows conversion of a u8 into a Unit. Defaults to Second if the u8 is not a valid Unit representation.
source§impl Mul<f64> for Unit
impl Mul<f64> for Unit
source§fn mul(self, q: f64) -> Duration
fn mul(self, q: f64) -> Duration
Creates a duration from that f64
Limitations
- If the input value times the unit does not fit on a Duration, then Duration::MAX or Duration::MIN will be returned depending on whether the value would have overflowed or underflowed (respectively).
- Floating point operations may round differently on different processors. It’s advised to use integer initialization of Durations whenever possible.
source§impl Ord for Unit
impl Ord for Unit
source§impl PartialEq for Unit
impl PartialEq for Unit
source§impl PartialOrd<Unit> for Duration
impl PartialOrd<Unit> for Duration
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd for Unit
impl PartialOrd for Unit
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl SubAssign<Unit> for Duration
impl SubAssign<Unit> for Duration
source§fn sub_assign(&mut self, rhs: Unit)
fn sub_assign(&mut self, rhs: Unit)
Performs the
-=
operation. Read moresource§impl SubAssign<Unit> for Epoch
impl SubAssign<Unit> for Epoch
source§fn sub_assign(&mut self, unit: Unit)
fn sub_assign(&mut self, unit: Unit)
Performs the
-=
operation. Read moreimpl Copy for Unit
impl Eq for Unit
impl StructuralEq for Unit
impl StructuralPartialEq for Unit
Auto Trait Implementations§
impl RefUnwindSafe for Unit
impl Send for Unit
impl Sync for Unit
impl Unpin for Unit
impl UnwindSafe for Unit
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more