Crate teamy_uom_extensions

Crate teamy_uom_extensions 

Source
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 KiB

Time

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 30s

InformationRate

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/s

That’s it — quick, minimal examples to demonstrate the core helpers. For full examples see the examples/ directory.

Structs§

FormatSizeOptions
Holds the options for the file_size method.

Constants§

BINARY
Options to display sizes in the SI format.
DECIMAL
Options to display sizes in the SI (decimal) format.

Traits§

HumanInformationExt
Trait with human-friendly formatting helpers for Information.
HumanInformationRateExt
Trait with human-friendly formatting helpers for InformationRate.
HumanTimeExt
Trait with human-friendly formatting helpers for Time.
InformationOverExt
Extension trait providing .over(time) to calculate rate as InformationRate<f64>.