Struct tor_units::IntegerMilliseconds
source · pub struct IntegerMilliseconds<T> { /* private fields */ }
Expand description
This type represents an integer number of milliseconds.
The underlying type should usually implement TryInto<u64>
.
Implementations§
source§impl<T> IntegerMilliseconds<T>
impl<T> IntegerMilliseconds<T>
sourcepub fn as_millis(self) -> T
pub fn as_millis(self) -> T
Deconstructor
Use only in contexts where it’s no longer possible to use the Rust type system to ensure secs vs ms vs us correctness.
sourcepub fn try_map<U, F, E>(self, f: F) -> Result<IntegerMilliseconds<U>, E>
pub fn try_map<U, F, E>(self, f: F) -> Result<IntegerMilliseconds<U>, E>
Map the inner value (useful for conversion)
§Example
use tor_units::{BoundedInt32, IntegerMilliseconds};
let value: IntegerMilliseconds<i32> = 42.into();
let value: IntegerMilliseconds<BoundedInt32<0,1000>>
= value.try_map(TryInto::try_into).unwrap();
Trait Implementations§
source§impl<T: Add<Output = T>> Add for IntegerMilliseconds<T>
impl<T: Add<Output = T>> Add for IntegerMilliseconds<T>
§type Output = IntegerMilliseconds<T>
type Output = IntegerMilliseconds<T>
The resulting type after applying the
+
operator.source§fn add(self, rhs: IntegerMilliseconds<T>) -> IntegerMilliseconds<T>
fn add(self, rhs: IntegerMilliseconds<T>) -> IntegerMilliseconds<T>
Performs the
+
operation. Read moresource§impl<T: Clone> Clone for IntegerMilliseconds<T>
impl<T: Clone> Clone for IntegerMilliseconds<T>
source§fn clone(&self) -> IntegerMilliseconds<T>
fn clone(&self) -> IntegerMilliseconds<T>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<T: Debug> Debug for IntegerMilliseconds<T>
impl<T: Debug> Debug for IntegerMilliseconds<T>
source§impl<T> Display for IntegerMilliseconds<T>where
T: Display,
impl<T> Display for IntegerMilliseconds<T>where
T: Display,
source§impl<T, __RhsT> Div<__RhsT> for IntegerMilliseconds<T>where
T: Div<__RhsT, Output = T>,
impl<T, __RhsT> Div<__RhsT> for IntegerMilliseconds<T>where
T: Div<__RhsT, Output = T>,
§type Output = IntegerMilliseconds<T>
type Output = IntegerMilliseconds<T>
The resulting type after applying the
/
operator.source§fn div(self, rhs: __RhsT) -> IntegerMilliseconds<T>
fn div(self, rhs: __RhsT) -> IntegerMilliseconds<T>
Performs the
/
operation. Read moresource§impl<T> From<T> for IntegerMilliseconds<T>
impl<T> From<T> for IntegerMilliseconds<T>
source§fn from(original: T) -> IntegerMilliseconds<T>
fn from(original: T) -> IntegerMilliseconds<T>
Converts to this type from the input type.
source§impl<T: FromStr> FromStr for IntegerMilliseconds<T>
impl<T: FromStr> FromStr for IntegerMilliseconds<T>
source§impl<T: Hash> Hash for IntegerMilliseconds<T>
impl<T: Hash> Hash for IntegerMilliseconds<T>
source§impl<T, __RhsT> Mul<__RhsT> for IntegerMilliseconds<T>where
T: Mul<__RhsT, Output = T>,
impl<T, __RhsT> Mul<__RhsT> for IntegerMilliseconds<T>where
T: Mul<__RhsT, Output = T>,
§type Output = IntegerMilliseconds<T>
type Output = IntegerMilliseconds<T>
The resulting type after applying the
*
operator.source§fn mul(self, rhs: __RhsT) -> IntegerMilliseconds<T>
fn mul(self, rhs: __RhsT) -> IntegerMilliseconds<T>
Performs the
*
operation. Read moresource§impl<T: Ord> Ord for IntegerMilliseconds<T>
impl<T: Ord> Ord for IntegerMilliseconds<T>
source§fn cmp(&self, other: &IntegerMilliseconds<T>) -> Ordering
fn cmp(&self, other: &IntegerMilliseconds<T>) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl<T: PartialEq> PartialEq for IntegerMilliseconds<T>
impl<T: PartialEq> PartialEq for IntegerMilliseconds<T>
source§fn eq(&self, other: &IntegerMilliseconds<T>) -> bool
fn eq(&self, other: &IntegerMilliseconds<T>) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl<T: PartialOrd> PartialOrd for IntegerMilliseconds<T>
impl<T: PartialOrd> PartialOrd for IntegerMilliseconds<T>
source§fn partial_cmp(&self, other: &IntegerMilliseconds<T>) -> Option<Ordering>
fn partial_cmp(&self, other: &IntegerMilliseconds<T>) -> Option<Ordering>
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<const H: i32, const L: i32> TryFrom<i32> for IntegerMilliseconds<BoundedInt32<H, L>>
impl<const H: i32, const L: i32> TryFrom<i32> for IntegerMilliseconds<BoundedInt32<H, L>>
impl<T: Copy> Copy for IntegerMilliseconds<T>
impl<T: Eq> Eq for IntegerMilliseconds<T>
impl<T> StructuralPartialEq for IntegerMilliseconds<T>
Auto Trait Implementations§
impl<T> Freeze for IntegerMilliseconds<T>where
T: Freeze,
impl<T> RefUnwindSafe for IntegerMilliseconds<T>where
T: RefUnwindSafe,
impl<T> Send for IntegerMilliseconds<T>where
T: Send,
impl<T> Sync for IntegerMilliseconds<T>where
T: Sync,
impl<T> Unpin for IntegerMilliseconds<T>where
T: Unpin,
impl<T> UnwindSafe for IntegerMilliseconds<T>where
T: UnwindSafe,
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