Crate human_size[−][src]
The human_size
represents sizes for humans.
The main type is SpecificSize
, which (as the name might suggests)
represents a size in specific multiple. Alternatively Size
can be used
to represent a size with a generic multiple (not defined at compile type).
Example
Below is small example that parses a size from a string and prints it
use human_size::{Size, SpecificSize, Kilobyte}; let size1: Size = "10000 B".parse().unwrap(); assert_eq!(size1.to_string(), "10000 B"); // Or using a specific multiple. let size2: SpecificSize<Kilobyte> = "10000 B".parse().unwrap(); assert_eq!(size2.to_string(), "10 kB"); // Generic and specific sizes can be compared. assert_eq!(size1, size2);
Notes
Internally f64
is used to represent the size, so when comparing sizes with
different multiples be wary of rounding errors related to usage of floating
point numbers.
Re-exports
pub use multiples::*; |
Modules
multiples |
Module containing all multiples. |
Structs
InvalidValueError |
The error returned when trying to create a new |
SpecificSize |
|
Enums
ParsingError |
The error returned when trying to parse a |
Traits
Multiple |
Trait to convert a |
Type Definitions
Size |
Size with a generic |