diff --git a/Cargo.lock b/Cargo.lock index 550225be..911a0910 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -576,9 +576,12 @@ checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" [[package]] name = "humansize" -version = "1.1.1" +version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02296996cb8796d7c6e3bc2d9211b7802812d36999a51bb754123ead7d37d026" +checksum = "6cb51c9a029ddc91b07a787f1d86b53ccfa49b0e86688c946ebe8d3555685dd7" +dependencies = [ + "libm", +] [[package]] name = "indexmap" @@ -626,6 +629,12 @@ version = "0.2.139" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" +[[package]] +name = "libm" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" + [[package]] name = "libusb1-sys" version = "0.6.2" diff --git a/Cargo.toml b/Cargo.toml index 63b08b6d..354fd4b4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ pcap-file = "2.0.0" tempfile = "3.3.0" bitfield = "0.13.2" num-format = "0.4.0" -humansize = "1.1.1" +humansize = "2.1.3" bisection = "0.1.0" derive_more = "0.99.17" rusb = "0.9.1" diff --git a/src/util.rs b/src/util.rs index cc383728..411a96e8 100644 --- a/src/util.rs +++ b/src/util.rs @@ -1,5 +1,5 @@ use num_format::{Locale, ToFormattedString}; -use humansize::{FileSize, file_size_opts as options}; +use humansize::{SizeFormatter, BINARY}; pub fn fmt_count(count: u64) -> String { count.to_formatted_string(&Locale::en) @@ -11,9 +11,6 @@ pub fn fmt_size(size: u64) -> String { } else if size < 1024 { format!("{size} bytes") } else { - match size.file_size(options::BINARY) { - Ok(string) => string, - Err(e) => format!("") - } + format!("{}", SizeFormatter::new(size, BINARY)) } }