MCPcopy Create free account
hub / github.com/evilsocket/cake / human_bytes

Function human_bytes

cake-cli/src/chat.rs:170–186  ·  view source on GitHub ↗
(bytes: u64)

Source from the content-addressed store, hash-verified

168// ── Helpers ────────────────────────────────────────────────────────────────
169
170fn human_bytes(bytes: u64) -> String {
171 if bytes == 0 {
172 return "0 B".to_string();
173 }
174 let units = ["B", "KB", "MB", "GB", "TB"];
175 let mut value = bytes as f64;
176 let mut unit_idx = 0;
177 while value >= 1024.0 && unit_idx < units.len() - 1 {
178 value /= 1024.0;
179 unit_idx += 1;
180 }
181 if unit_idx == 0 {
182 format!("{} B", bytes)
183 } else {
184 format!("{:.1} {}", value, units[unit_idx])
185 }
186}
187
188fn build_message_lines(app: &App, width: u16) -> Vec<Line<'static>> {
189 let mut lines: Vec<Line<'static>> = Vec::new();

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected