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

Function format_size

atomic-core/src/change/format_v3/chunking.rs:665–673  ·  view source on GitHub ↗

Format a byte size as a human-readable string (e.g., "64 KB", "1.2 MB").

(bytes: usize)

Source from the content-addressed store, hash-verified

663
664/// Format a byte size as a human-readable string (e.g., "64 KB", "1.2 MB").
665fn format_size(bytes: usize) -> String {
666 if bytes >= 1024 * 1024 {
667 format!("{:.1} MB", bytes as f64 / (1024.0 * 1024.0))
668 } else if bytes >= 1024 {
669 format!("{:.1} KB", bytes as f64 / 1024.0)
670 } else {
671 format!("{} B", bytes)
672 }
673}
674
675// ═══════════════════════════════════════════════════════════════════════
676// Tests

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected