Skip to main content

memory_string_to_bytes

Function memory_string_to_bytes 

Source
pub fn memory_string_to_bytes(value: &str) -> Option<u64>
Expand description

Convert a memory quantity string ("512Mi", "1Gi", "2Ti", "256Ki") into a byte count. Suffixes are binary (Ki = 1024, Mi = 1024², …).

Returns None if the value is malformed, lacks a recognized suffix, or overflows u64. The accepted grammar matches validate_memory_option_wrapper: a positive integer followed by one of Ki / Mi / Gi / Ti.