Skip to main content

format_bytes

Function format_bytes 

Source
pub fn format_bytes(bytes: u64) -> String
Expand description

Format a byte count into human-readable form using IEC binary prefixes.

§Arguments

  • bytes - Raw byte count

§Returns

Formatted string like "12.3 MiB" or "456 KiB"

§Example

use aria2_core::util::format::format_bytes;

assert_eq!(format_bytes(500), "500 B");
assert_eq!(format_bytes(2048), "2.00 KiB");
assert_eq!(format_bytes(1048576), "1.00 MiB");