pub struct ConfigSize(/* private fields */);Expand description
A size in bytes written as a number and a unit, such as 500M, 512Mi,
1Gi or 4096.
Decimal units are k, M, G, T, P and E, each a thousand times
the one before; binary units are Ki, Mi, Gi, Ti, Pi and Ei,
each 1024 times the one before. A unit may carry a trailing B, as in
512MiB, and a bare number is a number of bytes.
Implementations§
Source§impl ConfigSize
impl ConfigSize
pub const ZERO: ConfigSize
Sourcepub const MAX: ConfigSize
pub const MAX: ConfigSize
The largest size there is, which several settings use for “no limit”.
pub const fn from_bytes(bytes: u64) -> Self
Sourcepub const fn from_kib(kib: u64) -> Self
pub const fn from_kib(kib: u64) -> Self
A size of kib kibibytes, or the largest one when that overflows.
Sourcepub const fn from_mib(mib: u64) -> Self
pub const fn from_mib(mib: u64) -> Self
A size of mib mebibytes, or the largest one when that overflows.
Sourcepub const fn from_gib(gib: u64) -> Self
pub const fn from_gib(gib: u64) -> Self
A size of gib gibibytes, or the largest one when that overflows.
Sourcepub const fn from_mb(mb: u64) -> Self
pub const fn from_mb(mb: u64) -> Self
A size of mb megabytes, or the largest one when that overflows.
pub const fn as_bytes(self) -> u64
Sourcepub const fn as_usize(self) -> usize
pub const fn as_usize(self) -> usize
The size as a usize, or usize::MAX where it does not fit: a limit
past the address space is no limit at all.
pub const fn is_zero(self) -> bool
pub const fn saturating_sub(self, other: Self) -> Self
Source§impl ConfigSize
impl ConfigSize
Sourcepub fn from_str_with_unit(s: &str) -> Result<(Self, bool), ParseError>
pub fn from_str_with_unit(s: &str) -> Result<(Self, bool), ParseError>
Reads the format described on ConfigSize and says whether the text
carried a unit: "16G" and "4096B" did, "16000" and "1.5" did
not.
A setting that once counted megabytes refuses a string with no unit,
since "16000" would be sixteen kilobytes where 16000 meant sixteen
gigabytes; this is how such a setting tells the two apart.
Trait Implementations§
Source§impl Clone for ConfigSize
impl Clone for ConfigSize
impl Copy for ConfigSize
Source§impl Debug for ConfigSize
impl Debug for ConfigSize
Source§impl Default for ConfigSize
impl Default for ConfigSize
Source§impl<'de> Deserialize<'de> for ConfigSize
impl<'de> Deserialize<'de> for ConfigSize
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Source§impl Display for ConfigSize
impl Display for ConfigSize
impl Eq for ConfigSize
Source§impl From<ConfigSize> for u64
impl From<ConfigSize> for u64
Source§fn from(ConfigSize: ConfigSize) -> Self
fn from(ConfigSize: ConfigSize) -> Self
Source§impl From<u64> for ConfigSize
impl From<u64> for ConfigSize
Source§impl FromStr for ConfigSize
impl FromStr for ConfigSize
Source§impl Hash for ConfigSize
impl Hash for ConfigSize
Source§impl Ord for ConfigSize
impl Ord for ConfigSize
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for ConfigSize
impl PartialEq for ConfigSize
Source§impl PartialEq<u64> for ConfigSize
impl PartialEq<u64> for ConfigSize
Source§impl PartialOrd for ConfigSize
impl PartialOrd for ConfigSize
Source§impl PartialOrd<u64> for ConfigSize
impl PartialOrd<u64> for ConfigSize
Source§impl Serialize for ConfigSize
impl Serialize for ConfigSize
Source§fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>
Writes the Display form, with a trailing B when that
form has no unit: 0B and 1181116006B, not 0 and 1181116006. A
setting whose earlier spelling counted megabytes refuses a string with
no unit, so a configuration written back out has to carry one to reload.
impl StructuralPartialEq for ConfigSize
Auto Trait Implementations§
impl Forget for ConfigSize
impl Freeze for ConfigSize
impl RefUnwindSafe for ConfigSize
impl Send for ConfigSize
impl Sync for ConfigSize
impl Unpin for ConfigSize
impl UnsafeUnpin for ConfigSize
impl UnwindSafe for ConfigSize
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
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
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> ⓘ
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> ⓘ
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