Enum smart_config::metadata::SizeUnit
source · #[non_exhaustive]pub enum SizeUnit {
Bytes,
KiB,
MiB,
GiB,
}
Expand description
Unit of byte size measurement.
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.
Bytes
Base unit – bytes.
KiB
Binary kilobyte (aka kibibyte) = 1,024 bytes.
MiB
Binary megabyte (aka mibibyte) = 1,048,576 bytes.
GiB
Binary gigabyte (aka gibibyte) = 1,073,741,824 bytes.
Trait Implementations§
source§impl DeserializeParam<ByteSize> for SizeUnit
impl DeserializeParam<ByteSize> for SizeUnit
Supports deserializing a ByteSize
from a number, with self
being the unit of measurement.
§Examples
use smart_config::testing;
#[derive(DescribeConfig, DeserializeConfig)]
struct TestConfig {
#[config(with = SizeUnit::MiB)]
size_mb: ByteSize,
}
let source = smart_config::config!("size_mb": 4);
let config = testing::test::<TestConfig>(source)?;
assert_eq!(config.size_mb, ByteSize(4 << 20));
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<ByteSize, ErrorWithOrigin>
fn deserialize_param( &self, ctx: DeserializeContext<'_>, param: &'static ParamMetadata, ) -> Result<ByteSize, ErrorWithOrigin>
Performs deserialization given the context and param metadata. Read more
source§impl From<SizeUnit> for UnitOfMeasurement
impl From<SizeUnit> for UnitOfMeasurement
impl Copy for SizeUnit
impl Eq for SizeUnit
impl StructuralPartialEq for SizeUnit
Auto Trait Implementations§
impl Freeze for SizeUnit
impl RefUnwindSafe for SizeUnit
impl Send for SizeUnit
impl Sync for SizeUnit
impl Unpin for SizeUnit
impl UnwindSafe for SizeUnit
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.