pub trait NumBytesExt {
// Required methods
fn bytes(self) -> NumBytes;
fn kilobytes(self) -> NumBytes;
fn megabytes(self) -> NumBytes;
}Expand description
Extension trait providing convenience constructors for NumBytes.
Implemented for usize, so integer literals can be used directly:
use tokio_process_tools::{NumBytes, NumBytesExt};
let small: NumBytes = 512.bytes();
let medium: NumBytes = 16.kilobytes();
let large: NumBytes = 2.megabytes();
assert_eq!(small.bytes(), 512);
assert_eq!(medium.bytes(), 16 * 1024);
assert_eq!(large.bytes(), 2 * 1024 * 1024);