pub enum TimeUnit {
Nanosecond,
Microsecond,
Millisecond,
Second,
Minute,
Hour,
Day,
Week,
Century,
}
Expand description
An Enum to perform time unit conversions.
Variants§
Nanosecond
Microsecond
Millisecond
Second
Minute
Hour
Day
Week
Century
36525 days, is the number of days per century in the Julian calendar
Implementations§
§impl Unit
impl Unit
pub fn in_seconds(&self) -> f64
pub fn from_seconds(&self) -> f64
Trait Implementations§
§impl AddAssign<Unit> for Duration
impl AddAssign<Unit> for Duration
§fn add_assign(&mut self, rhs: Unit)
fn add_assign(&mut self, rhs: Unit)
Performs the
+=
operation. Read more§impl AddAssign<Unit> for Epoch
impl AddAssign<Unit> for Epoch
§fn add_assign(&mut self, unit: Unit)
fn add_assign(&mut self, unit: Unit)
Performs the
+=
operation. Read more§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.
§impl Mul<f64> for Unit
impl Mul<f64> for Unit
§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.
§impl Ord for Unit
impl Ord for Unit
§impl PartialOrd<Unit> for Duration
impl PartialOrd<Unit> for Duration
§impl PartialOrd for Unit
impl PartialOrd for Unit
§impl SubAssign<Unit> for Duration
impl SubAssign<Unit> for Duration
§fn sub_assign(&mut self, rhs: Unit)
fn sub_assign(&mut self, rhs: Unit)
Performs the
-=
operation. Read more§impl SubAssign<Unit> for Epoch
impl SubAssign<Unit> for Epoch
§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 StructuralPartialEq for Unit
Auto Trait Implementations§
impl Freeze for Unit
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.