pub struct BoundedSecs<const MIN: u64, const MAX: u64>(/* private fields */);Expand description
A whole number of seconds in MIN..=MAX, with MIN >= 1.
Deserializes from a TOML integer and rejects out-of-range values at load time, so an embedder cannot build an out-of-range value either.
§Examples
use std::time::Duration;
use mcpls_core::config::TimeoutSecs;
assert!(TimeoutSecs::new(0).is_err());
assert!(TimeoutSecs::new(901).is_err());
assert_eq!(TimeoutSecs::new(45).unwrap().as_duration(), Duration::from_secs(45));Implementations§
Source§impl<const MIN: u64, const MAX: u64> BoundedSecs<MIN, MAX>
impl<const MIN: u64, const MAX: u64> BoundedSecs<MIN, MAX>
Sourcepub const fn new(secs: u64) -> Result<Self, InvalidSecs>
pub const fn new(secs: u64) -> Result<Self, InvalidSecs>
Sourcepub const fn as_duration(self) -> Duration
pub const fn as_duration(self) -> Duration
The wrapped number of seconds as a Duration.
Source§impl BoundedSecs<1, MAX_TIMEOUT_SECONDS>
impl BoundedSecs<1, MAX_TIMEOUT_SECONDS>
Source§impl BoundedSecs<{ PROGRESS_SETTLE.as_secs() + 1 }, { INDEXING_STALENESS_BOUND.as_secs() - 1 }>
impl BoundedSecs<{ PROGRESS_SETTLE.as_secs() + 1 }, { INDEXING_STALENESS_BOUND.as_secs() - 1 }>
Trait Implementations§
impl<const MIN: u64, const MAX: u64> Copy for BoundedSecs<MIN, MAX>
Source§impl<'de, const MIN: u64, const MAX: u64> Deserialize<'de> for BoundedSecs<MIN, MAX>
impl<'de, const MIN: u64, const MAX: u64> Deserialize<'de> for BoundedSecs<MIN, MAX>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl<const MIN: u64, const MAX: u64> Eq for BoundedSecs<MIN, MAX>
Source§impl<const MIN: u64, const MAX: u64> From<BoundedSecs<MIN, MAX>> for u64
impl<const MIN: u64, const MAX: u64> From<BoundedSecs<MIN, MAX>> for u64
Source§fn from(value: BoundedSecs<MIN, MAX>) -> Self
fn from(value: BoundedSecs<MIN, MAX>) -> Self
Converts to this type from the input type.
impl<const MIN: u64, const MAX: u64> StructuralPartialEq for BoundedSecs<MIN, MAX>
Auto Trait Implementations§
impl<const MIN: u64, const MAX: u64> Freeze for BoundedSecs<MIN, MAX>
impl<const MIN: u64, const MAX: u64> RefUnwindSafe for BoundedSecs<MIN, MAX>
impl<const MIN: u64, const MAX: u64> Send for BoundedSecs<MIN, MAX>
impl<const MIN: u64, const MAX: u64> Sync for BoundedSecs<MIN, MAX>
impl<const MIN: u64, const MAX: u64> Unpin for BoundedSecs<MIN, MAX>
impl<const MIN: u64, const MAX: u64> UnsafeUnpin for BoundedSecs<MIN, MAX>
impl<const MIN: u64, const MAX: u64> UnwindSafe for BoundedSecs<MIN, MAX>
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<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.