MCPcopy Create free account
hub / github.com/ChrisFeldmeier/OpenCodeRust / format_bytes

Function format_bytes

crates/opencode-util/src/util.rs:140–154  ·  view source on GitHub ↗
(bytes: u64)

Source from the content-addressed store, hash-verified

138 }
139
140 pub fn format_bytes(bytes: u64) -> String {
141 const KB: u64 = 1024;
142 const MB: u64 = KB * 1024;
143 const GB: u64 = MB * 1024;
144
145 if bytes >= GB {
146 format!("{:.1} GB", bytes as f64 / GB as f64)
147 } else if bytes >= MB {
148 format!("{:.1} MB", bytes as f64 / MB as f64)
149 } else if bytes >= KB {
150 format!("{:.1} KB", bytes as f64 / KB as f64)
151 } else {
152 format!("{} B", bytes)
153 }
154 }
155
156 pub fn format_number(n: u64) -> String {
157 if n >= 1_000_000 {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected