(bytes: u64)
| 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 { |
nothing calls this directly
no outgoing calls
no test coverage detected