Skip to content

Commit 2d25d65

Browse files
committed
feat: add hm-common crate with compact duration formatting
Introduce the hm-common crate, seeded with a formatting module: a sealed CompactDuration extension trait on std::time::Duration returning a StopwatchDurationDisplay (allocation-free Display wrapper). Rendering follows humantime semantics — lossless, most-significant unit first, zero units omitted — in compact notation (1s500ms, 1h1m1s, 2h, 1d2h). Covered by rstest cases plus proptest round-trip/well-formedness. Wire it into hm-render's progress output, replacing the hand-rolled format_duration (which capped at minutes, so >=1h rendered as e.g. "61m1s"). Machine-facing "duration={ms}ms" log lines stay integer ms. Also adopt the human_units crate for byte-size rendering, collapsing four hand-rolled formatters (human_mb, human_bytes, and an inline mb closure) into `.format_size()`. Output shifts to correct IEC labels (e.g. "6 MiB" instead of the mislabeled 1024-base "6.0 MB").
1 parent 17e6964 commit 2d25d65

13 files changed

Lines changed: 428 additions & 63 deletions

File tree

‎Cargo.lock‎

Lines changed: 203 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
resolver = "2"
33
members = [
44
"crates/hm",
5+
"crates/hm-common",
56
"crates/hm-config",
67
"crates/hm-plugin-protocol",
78
"crates/hm-pipeline-ir",
@@ -14,6 +15,7 @@ members = [
1415
]
1516
default-members = [
1617
"crates/hm",
18+
"crates/hm-common",
1719
"crates/hm-config",
1820
"crates/hm-plugin-protocol",
1921
"crates/hm-pipeline-ir",
@@ -40,6 +42,7 @@ hm-config = { path = "crates/hm-config", version = "0.0.0-dev"
4042
hm-dsl-engine = { path = "crates/hm-dsl-engine", version = "0.0.0-dev" }
4143
hm-render = { path = "crates/hm-render", version = "0.0.0-dev" }
4244
hm-vm = { path = "crates/hm-vm", version = "0.0.0-dev" }
45+
hm-common = { path = "crates/hm-common", version = "0.0.0-dev" }
4346
harmont-cloud = "0.2"
4447
harmont-cloud-raw = "0.2"
4548
anyhow = "1"
@@ -54,6 +57,7 @@ semver = { version = "1", features = ["serde"] }
5457
uuid = { version = "1", features = ["serde", "v4"] }
5558
chrono = { version = "0.4", features = ["serde"] }
5659
thiserror = "2"
60+
human-units = "0.5.4"
5761
derive_more = { version = "1", default-features = false, features = ["full"] }
5862
smart-default = "0.7"
5963
tokio = { version = "1", features = ["full"] }

0 commit comments

Comments
 (0)