pub struct MemSize(/* private fields */);Expand description
A memory quantity in bytes, used for memory-limit thresholds
Parses the Flockfile grammar ^\d+(G|M|K)?$ (binary units; plain digits
are bytes). Ordering compares byte counts, so a configured limit compares
directly against a sampled RSS wrapped with MemSize::from_bytes.
§Example
use shep_core::values::MemSize;
let limit: MemSize = "512M".parse()?;
assert_eq!(limit.bytes(), 512 << 20);
assert!("512MB".parse::<MemSize>().is_err()); // strict grammarImplementations§
Trait Implementations§
impl Copy for MemSize
Source§impl<'de> Deserialize<'de> for MemSize
impl<'de> Deserialize<'de> for MemSize
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 MemSize
Formats with the largest binary unit dividing the value exactly;
output always re-parses to the same value
impl Display for MemSize
Formats with the largest binary unit dividing the value exactly; output always re-parses to the same value
impl Eq for MemSize
Source§impl FromStr for MemSize
impl FromStr for MemSize
Source§fn from_str(s: &str) -> Result<Self, Self::Err>
fn from_str(s: &str) -> Result<Self, Self::Err>
Parses ^\d+(G|M|K)?$: binary units, plain digits = bytes
§Errors
ParseMemSizeError::Empty: empty input.ParseMemSizeError::MissingDigits: unit suffix with no digits.ParseMemSizeError::InvalidCharacter: anything outside ASCII digits plus one trailingG/M/K(lowercase, whitespace, fractions, multi-letter suffixes all land here).ParseMemSizeError::Overflow: byte count exceedsu64::MAX.
Source§type Err = ParseMemSizeError
type Err = ParseMemSizeError
Source§impl JsonSchema for MemSize
Available on crate feature schema only.String-shaped, matching this type’s Serialize/Deserialize, which go
through Display/FromStr rather than the wrapped u64. A derive here
would emit {"type":"integer"} and describe a wire form that does not
exist.
impl JsonSchema for MemSize
schema only.String-shaped, matching this type’s Serialize/Deserialize, which go
through Display/FromStr rather than the wrapped u64. A derive here
would emit {"type":"integer"} and describe a wire form that does not
exist.
The pattern is FromStr’s own grammar, lifted from its doc comment
above. If you change one, change the other: the paired test below is
what catches it.
Source§fn json_schema(_: &mut SchemaGenerator) -> Schema
fn json_schema(_: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl Ord for MemSize
impl Ord for MemSize
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 PartialOrd for MemSize
impl PartialOrd for MemSize
impl StructuralPartialEq for MemSize
Auto Trait Implementations§
impl Freeze for MemSize
impl RefUnwindSafe for MemSize
impl Send for MemSize
impl Sync for MemSize
impl Unpin for MemSize
impl UnsafeUnpin for MemSize
impl UnwindSafe for MemSize
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.