Crate lib[][src]

Expand description

This crate provides a simple Bytes struct that stores a number and displays it in as the appropriate multiple of a power of 1000 bytes, i.e. in Megabytes, Gigabyte, etc. for human readability.

Example:

let b = Bytes(5247 as u16);
println!("{}", b)  //  Prints "5.25 KB"

The number is stored internally in the same type as was provided to initialize the struct: u16 in this example.

Structs

The actual struct. Trait bounds specify what traits are required from the type used to store the number of bytes. Into<u64> in particular is required as the number of bytes is temporarily converted to u64 (the only type that we are sure can store any number stored in another type without overflowing) to compare it.

Traits

Marker trait used to indicate to the compiler what types are allowed to initialize the struct.