Function parse_size::parse_size [−][src]
pub fn parse_size<T: AsRef<[u8]>>(src: T) -> Result<u64, Error>
Parses the string input into the number of bytes it represents using the default configuration.
Equivalent to calling Config::parse_size()
with the default
configuration (Config::new()
).
Examples
use parse_size::{parse_size, Error}; assert_eq!(parse_size("10 KB"), Ok(10000)); assert_eq!(parse_size("20000"), Ok(20000)); assert_eq!(parse_size("0.2 MiB"), Ok(209715)); assert_eq!(parse_size("^_^"), Err(Error::InvalidDigit));