pub struct ConfigDuration(/* private fields */);Expand description
A duration written as a number and a unit, such as 500ms, 30s, 1h30m
or 30d.
Accepted units are ns, us (or µs), ms, s, m, h, and d. A
value may chain several terms, as in 1h30m, and the terms are summed. A
bare 0 is also accepted.
Implementations§
Source§impl ConfigDuration
impl ConfigDuration
pub const ZERO: ConfigDuration
pub const fn from_nanos(nanos: u64) -> Self
pub const fn from_micros(micros: u64) -> Self
pub const fn from_millis(millis: u64) -> Self
pub const fn from_secs(secs: u64) -> Self
Sourcepub const fn from_days(days: u64) -> Self
pub const fn from_days(days: u64) -> Self
A duration of days days, or the longest one there is when that many
days do not fit in a u64 of seconds.
pub const fn as_micros(self) -> u128
pub const fn as_millis(self) -> u128
pub const fn as_secs(self) -> u64
pub fn as_secs_f64(self) -> f64
pub const fn is_zero(self) -> bool
Trait Implementations§
Source§impl Clone for ConfigDuration
impl Clone for ConfigDuration
impl Copy for ConfigDuration
Source§impl Debug for ConfigDuration
impl Debug for ConfigDuration
Source§impl Default for ConfigDuration
impl Default for ConfigDuration
Source§impl<'de> Deserialize<'de> for ConfigDuration
impl<'de> Deserialize<'de> for ConfigDuration
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for ConfigDuration
impl Display for ConfigDuration
impl Eq for ConfigDuration
Source§impl From<ConfigDuration> for Duration
impl From<ConfigDuration> for Duration
Source§fn from(ConfigDuration: ConfigDuration) -> Self
fn from(ConfigDuration: ConfigDuration) -> Self
Converts to this type from the input type.
Source§impl From<Duration> for ConfigDuration
impl From<Duration> for ConfigDuration
Source§impl FromStr for ConfigDuration
impl FromStr for ConfigDuration
Source§fn from_str(s: &str) -> Result<Self, Self::Err>
fn from_str(s: &str) -> Result<Self, Self::Err>
Reads the format described on ConfigDuration: a run of terms, each a
number and a unit, summed together.
The scan walks the string once. Each term contributes
whole * unit + round(fraction * unit), accumulated in nanoseconds as a
u128, so no step goes through floating point and a value near the top
of the representable range keeps every digit.
Source§type Err = ParseError
type Err = ParseError
The associated error which can be returned from parsing.
Source§impl Hash for ConfigDuration
impl Hash for ConfigDuration
Source§impl Ord for ConfigDuration
impl Ord for ConfigDuration
1.21.0 (const: unstable) · 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
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialEq for ConfigDuration
impl PartialEq for ConfigDuration
Source§impl PartialEq<Duration> for ConfigDuration
impl PartialEq<Duration> for ConfigDuration
Source§impl PartialOrd for ConfigDuration
impl PartialOrd for ConfigDuration
Source§impl PartialOrd<Duration> for ConfigDuration
impl PartialOrd<Duration> for ConfigDuration
Source§impl Serialize for ConfigDuration
impl Serialize for ConfigDuration
impl StructuralPartialEq for ConfigDuration
Auto Trait Implementations§
impl Forget for ConfigDuration
impl Freeze for ConfigDuration
impl RefUnwindSafe for ConfigDuration
impl Send for ConfigDuration
impl Sync for ConfigDuration
impl Unpin for ConfigDuration
impl UnsafeUnpin for ConfigDuration
impl UnwindSafe for ConfigDuration
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§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§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> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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