Skip to main content

parse_bytes

Function parse_bytes 

Source
pub fn parse_bytes(s: &str) -> Option<u64>
Expand description

Parses human-readable sizes (e.g. "5MB", "10KB", "2GB") into a raw byte count (u64). Case-insensitive, supports optional space, and treats unit-less values as bytes.

ยงExamples

use rskit_util::bytes::parse_bytes;
assert_eq!(parse_bytes("512"), Some(512));
assert_eq!(parse_bytes("1 KB"), Some(1024));
assert_eq!(parse_bytes("5mb"), Some(5242880));