Function gluster::translate_to_bytes [] [src]

pub fn translate_to_bytes<T>(value: &str) -> Option<T> where
    T: FromStr + Mul<Output = T> + Copy

This is a helper function to convert values such as 1PB into a bytes

Examples

extern crate gluster;
let bytes: u64 = gluster::translate_to_bytes("1GB").unwrap();
assert_eq!(bytes, 1073741824);
let bytes: f64 = gluster::translate_to_bytes("1.0GB").unwrap();
assert_eq!(bytes, 1073741824.0);