Skip to main content

Module format

Module format 

Source
Expand description

Display formatting for download rates and durations.

Shared by every Rust renderer (the CLI progress bars in gglib-download) and mirrored exactly by formatRate / formatDuration in src/utils/format.ts so the CLI, the Tauri GUI and the web UI all render the same number the same way.

ยงUnits

Rates are decimal โ€” 1 MB/s is 1,000,000 bytes per second. This matches Activity Monitor, nettop, iftop and every ISP, which is what users compare a download speed against.

Sizes stay binary (MiB, GiB) because that is the convention for model files on disk, and are rendered by indicatifโ€™s HumanBytes, which already labels them correctly. Do not use this module for sizes.

Constantsยง

GB ๐Ÿ”’
KB ๐Ÿ”’
MB ๐Ÿ”’
UNKNOWN
Placeholder rendered when a value is not yet known.

Functionsยง

format_duration
Format a duration in seconds as 45s, 3m 20s or 1h 04m.
format_rate
Format a transfer rate in decimal units, e.g. 118.4 MB/s.