| 168 | // ── Helpers ──────────────────────────────────────────────────────────────── |
| 169 | |
| 170 | fn 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 | |
| 188 | fn build_message_lines(app: &App, width: u16) -> Vec<Line<'static>> { |
| 189 | let mut lines: Vec<Line<'static>> = Vec::new(); |