Crate human_size [] [src]

The human_size represents sizes for humans. The main type is Size, which (as the name might suggests) represents a size in multiple of bytes.

Example

Below is small example that parses a size from a string, prints it and get the size in bytes.

use human_size::Size;
let size = "100 KB".parse::<Size>().unwrap();
println!("size: {}", size); // 100 KB

let bytes = size.into_bytes();
println!("size in bytes: {}", bytes); // 102400

Structs

Size

Size represents a size in bytes. Size can be created using the new function, or parsed from a string using the FromStr trait.

Enums

Multiple

A Multiple represent a multiple of bytes. This is mainly used to keep track of what multiple Size uses, so it can display it using the same multiple of bytes.

ParsingError

The error returned when trying to parse a Size or Mulitple from a string, using the FromStr trait.