MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / format_bytes

Function format_bytes

atomic-cli/tests/fixtures/helpers_c5.rs:406–414  ·  view source on GitHub ↗

Format a byte count for display.

(bytes: u64)

Source from the content-addressed store, hash-verified

404
405/// Format a byte count for display.
406fn format_bytes(bytes: u64) -> String {
407 if bytes >= 1024 * 1024 {
408 format!("{:.1} MB", bytes as f64 / (1024.0 * 1024.0))
409 } else if bytes >= 1024 {
410 format!("{:.1} KB", bytes as f64 / 1024.0)
411 } else {
412 format!("{} B", bytes)
413 }
414}
415
416// =============================================================================
417// Error Conversion

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected