(bytes: u64)
| 670 | } |
| 671 | |
| 672 | pub fn format_bytes(bytes: u64) -> String { |
| 673 | const KB: u64 = 1024; |
| 674 | const MB: u64 = KB * 1024; |
| 675 | const GB: u64 = MB * 1024; |
| 676 | |
| 677 | if bytes >= GB { |
| 678 | format!("{:.1} GB", bytes as f64 / GB as f64) |
| 679 | } else if bytes >= MB { |
| 680 | format!("{:.1} MB", bytes as f64 / MB as f64) |
| 681 | } else if bytes >= KB { |
| 682 | format!("{:.1} KB", bytes as f64 / KB as f64) |
| 683 | } else { |
| 684 | format!("{} B", bytes) |
| 685 | } |
| 686 | } |
| 687 | |
| 688 | // Tests |
| 689 |
nothing calls this directly
no outgoing calls
no test coverage detected