Expand description
teamy-uom-extensions
Small companion crate providing human-friendly display helpers for uom types
(uses humantime and humansize if the human feature is enabled).
This crate intentionally focuses on the f64 SI aliases from uom for the most
convenient runtime-friendly formatting of values like Time, Information and
InformationRate.
§teamy-uom-extensions — quick demo
Tiny examples showing the core formatting helpers. These examples use the default features
(human) so formatting helpers are available out of the box.
Information (bytes)
use teamy_uom_extensions::{HumanInformationExt, DECIMAL, BINARY};
use uom::si::f64::Information;
use uom::si::information::byte;
let i = Information::new::<byte>(1536.0);
println!("dec: {} bin: {}", i.format_human(DECIMAL), i.format_human(BINARY));Output (example):
dec: 1.54 kB bin: 1.50 KiBTime
use teamy_uom_extensions::HumanTimeExt;
use uom::si::f64::Time;
use uom::si::time::second;
let t = Time::new::<second>(90.0);
println!("human: {} precise: {}", t.format_human(), t.format_human_precise());Output (example):
human: 1m 30s precise: 1m 30sInformationRate
use teamy_uom_extensions::{HumanInformationRateExt, DECIMAL};
use uom::si::f64::InformationRate;
use uom::si::information_rate::byte_per_second;
let r = InformationRate::new::<byte_per_second>(2048.0);
println!("rate: {}", r.format_human(DECIMAL));Output (example):
rate: 2.05 kB/sThat’s it — quick, minimal examples to demonstrate the core helpers. For full examples see the examples/ directory.
Structs§
- Format
Size Options - Holds the options for the
file_sizemethod.
Constants§
- BINARY
- Options to display sizes in the SI format.
- DECIMAL
- Options to display sizes in the SI (decimal) format.
Traits§
- Human
Information Ext - Trait with human-friendly formatting helpers for
Information. - Human
Information Rate Ext - Trait with human-friendly formatting helpers for
InformationRate. - Human
Time Ext - Trait with human-friendly formatting helpers for
Time. - Information
Over Ext - Extension trait providing
.over(time)to calculate rate asInformationRate<f64>.