pub struct IntegerSeconds<T> {
pub(crate) value: T,
}
Expand description
This type represents an integer number of seconds.
The underlying type should usually implement TryInto<u64>
.
Fields§
§value: T
Interior Value. Should implement TryInto<u64>
to be useful.
Implementations§
Source§impl<T> IntegerSeconds<T>
impl<T> IntegerSeconds<T>
Sourcepub fn as_secs(self) -> T
pub fn as_secs(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<IntegerSeconds<U>, E>
pub fn try_map<U, F, E>(self, f: F) -> Result<IntegerSeconds<U>, E>
Map the inner value (useful for conversion)
use tor_units::{BoundedInt32, IntegerSeconds};
let value: IntegerSeconds<i32> = 42.into();
let value: IntegerSeconds<BoundedInt32<0,1000>>
= value.try_map(TryInto::try_into).unwrap();
Trait Implementations§
Source§impl<T: Add<Output = T>> Add for IntegerSeconds<T>
impl<T: Add<Output = T>> Add for IntegerSeconds<T>
Source§type Output = IntegerSeconds<T>
type Output = IntegerSeconds<T>
The resulting type after applying the
+
operator.Source§fn add(self, rhs: IntegerSeconds<T>) -> IntegerSeconds<T>
fn add(self, rhs: IntegerSeconds<T>) -> IntegerSeconds<T>
Performs the
+
operation. Read moreSource§impl<T: Clone> Clone for IntegerSeconds<T>
impl<T: Clone> Clone for IntegerSeconds<T>
Source§fn clone(&self) -> IntegerSeconds<T>
fn clone(&self) -> IntegerSeconds<T>
Returns a duplicate 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 IntegerSeconds<T>
impl<T: Debug> Debug for IntegerSeconds<T>
Source§impl<T> Display for IntegerSeconds<T>where
T: Display,
impl<T> Display for IntegerSeconds<T>where
T: Display,
Source§impl<T, __RhsT> Div<__RhsT> for IntegerSeconds<T>where
T: Div<__RhsT, Output = T>,
impl<T, __RhsT> Div<__RhsT> for IntegerSeconds<T>where
T: Div<__RhsT, Output = T>,
Source§type Output = IntegerSeconds<T>
type Output = IntegerSeconds<T>
The resulting type after applying the
/
operator.Source§fn div(self, rhs: __RhsT) -> IntegerSeconds<T>
fn div(self, rhs: __RhsT) -> IntegerSeconds<T>
Performs the
/
operation. Read moreSource§impl<T> From<T> for IntegerSeconds<T>
impl<T> From<T> for IntegerSeconds<T>
Source§impl<T: FromStr> FromStr for IntegerSeconds<T>
impl<T: FromStr> FromStr for IntegerSeconds<T>
Source§impl<T: Hash> Hash for IntegerSeconds<T>
impl<T: Hash> Hash for IntegerSeconds<T>
Source§impl<T, __RhsT> Mul<__RhsT> for IntegerSeconds<T>where
T: Mul<__RhsT, Output = T>,
impl<T, __RhsT> Mul<__RhsT> for IntegerSeconds<T>where
T: Mul<__RhsT, Output = T>,
Source§type Output = IntegerSeconds<T>
type Output = IntegerSeconds<T>
The resulting type after applying the
*
operator.Source§fn mul(self, rhs: __RhsT) -> IntegerSeconds<T>
fn mul(self, rhs: __RhsT) -> IntegerSeconds<T>
Performs the
*
operation. Read moreSource§impl<T: Ord> Ord for IntegerSeconds<T>
impl<T: Ord> Ord for IntegerSeconds<T>
Source§fn cmp(&self, other: &IntegerSeconds<T>) -> Ordering
fn cmp(&self, other: &IntegerSeconds<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 IntegerSeconds<T>
impl<T: PartialEq> PartialEq for IntegerSeconds<T>
Source§impl<T: PartialOrd> PartialOrd for IntegerSeconds<T>
impl<T: PartialOrd> PartialOrd for IntegerSeconds<T>
Source§impl<const H: i32, const L: i32> TryFrom<i32> for IntegerSeconds<BoundedInt32<H, L>>
impl<const H: i32, const L: i32> TryFrom<i32> for IntegerSeconds<BoundedInt32<H, L>>
impl<T: Copy> Copy for IntegerSeconds<T>
impl<T: Eq> Eq for IntegerSeconds<T>
impl<T> StructuralPartialEq for IntegerSeconds<T>
Auto Trait Implementations§
impl<T> Freeze for IntegerSeconds<T>where
T: Freeze,
impl<T> RefUnwindSafe for IntegerSeconds<T>where
T: RefUnwindSafe,
impl<T> Send for IntegerSeconds<T>where
T: Send,
impl<T> Sync for IntegerSeconds<T>where
T: Sync,
impl<T> Unpin for IntegerSeconds<T>where
T: Unpin,
impl<T> UnwindSafe for IntegerSeconds<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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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