Skip to main content

parse_byte_count

Function parse_byte_count 

Source
pub fn parse_byte_count(s: &str) -> Result<u64, String>
Expand description

Parses a byte size with the same grammar as ByteSize, as a u64.

Unlike ByteSize, whose range is usize, this accepts sizes of 4 GiB and above on 32-bit targets. Use it for sizes that describe files or totals rather than in-memory buffers, e.g. a log file size limit.

assert_eq!(dora_message::config::parse_byte_count("8GB"), Ok(8 << 30));
assert!(dora_message::config::parse_byte_count("-1KB").is_err());