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

Function format_bytes

atomic-cli/src/commands/clone/helpers.rs:672–686  ·  view source on GitHub ↗
(bytes: u64)

Source from the content-addressed store, hash-verified

670}
671
672pub fn format_bytes(bytes: u64) -> String {
673 const KB: u64 = 1024;
674 const MB: u64 = KB * 1024;
675 const GB: u64 = MB * 1024;
676
677 if bytes >= GB {
678 format!("{:.1} GB", bytes as f64 / GB as f64)
679 } else if bytes >= MB {
680 format!("{:.1} MB", bytes as f64 / MB as f64)
681 } else if bytes >= KB {
682 format!("{:.1} KB", bytes as f64 / KB as f64)
683 } else {
684 format!("{} B", bytes)
685 }
686}
687
688// Tests
689

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected