iroh_util/
human.rs

1use humansize::{format_size, DECIMAL};
2
3/// Format byte count as a human-readable size string eg: 1_000_000u64 -> "1 MB"
4/// this func isolates a library + configuration choice
5pub fn format_bytes(size: u64) -> String {
6    format_size(size, DECIMAL)
7}
8
9#[cfg(test)]
10mod tests {
11    use super::*;
12    #[test]
13    fn test_format_bytes() {
14        assert_eq!(format_bytes(1_000_000u64), "1 MB");
15    }
16}