Function bytefmt::parse_to

source ·
pub fn parse_to<S: Into<String>>(
    str: S,
    result_unit: Unit
) -> Result<f64, &'static str>
Expand description

Parse given string to specific byte unit

Examples

let kb = bytefmt::parse_to("123B", bytefmt::Unit::KB).unwrap();
let mb = bytefmt::parse_to("123B", bytefmt::Unit::MB).unwrap();
 
assert_eq!(kb, 0.123);
assert_eq!(mb, 0.000123);