Enum smart_config::metadata::TimeUnit
source · #[non_exhaustive]pub enum TimeUnit {
Millis,
Seconds,
Minutes,
Hours,
Days,
Weeks,
}
Expand description
Unit of time measurement.
§Examples
You can use multiplication to define durations (e.g., for parameter values):
let dur = 5 * TimeUnit::Hours;
assert_eq!(dur, Duration::from_secs(5 * 3_600));
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Millis
Millisecond (0.001 seconds).
Seconds
Base unit – second.
Minutes
Minute (60 seconds).
Hours
Hour (3,600 seconds).
Days
Day (86,400 seconds).
Weeks
Week (7 days).
Implementations§
Trait Implementations§
source§impl DeserializeParam<Duration> for TimeUnit
impl DeserializeParam<Duration> for TimeUnit
Supports deserializing a Duration
from a number, with self
being the unit of measurement.
§Examples
use smart_config::testing;
#[derive(DescribeConfig, DeserializeConfig)]
struct TestConfig {
#[config(with = TimeUnit::Millis)]
time_ms: Duration,
}
let source = smart_config::config!("time_ms": 100);
let config = testing::test::<TestConfig>(source)?;
assert_eq!(config.time_ms, Duration::from_millis(100));
source§const EXPECTING: BasicTypes = BasicTypes::INTEGER
const EXPECTING: BasicTypes = BasicTypes::INTEGER
Describes which parameter this deserializer is expecting.
source§fn describe(&self, description: &mut TypeDescription)
fn describe(&self, description: &mut TypeDescription)
Additional info about the deserialized type, e.g., extended description.
source§fn deserialize_param(
&self,
ctx: DeserializeContext<'_>,
param: &'static ParamMetadata,
) -> Result<Duration, ErrorWithOrigin>
fn deserialize_param( &self, ctx: DeserializeContext<'_>, param: &'static ParamMetadata, ) -> Result<Duration, ErrorWithOrigin>
Performs deserialization given the context and param metadata. Read more
source§impl From<TimeUnit> for UnitOfMeasurement
impl From<TimeUnit> for UnitOfMeasurement
impl Copy for TimeUnit
impl Eq for TimeUnit
impl StructuralPartialEq for TimeUnit
Auto Trait Implementations§
impl Freeze for TimeUnit
impl RefUnwindSafe for TimeUnit
impl Send for TimeUnit
impl Sync for TimeUnit
impl Unpin for TimeUnit
impl UnwindSafe for TimeUnit
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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
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> 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.