From 076d6a0546d4fbe84ac013d318ff043a56947ca8 Mon Sep 17 00:00:00 2001 From: ClementTsang Date: Wed, 11 Dec 2019 01:01:40 -0500 Subject: [PATCH] Changed network data to show decimal point. --- src/convert_data.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/convert_data.rs b/src/convert_data.rs index 864f68ba..2fdf91e4 100644 --- a/src/convert_data.rs +++ b/src/convert_data.rs @@ -287,31 +287,31 @@ pub fn convert_network_data_points(network_data: &[data_collection::network::Net let rx_display = if let Some(last_num_bytes_entry) = network_data.last() { let num_bytes = last_num_bytes_entry.rx; if num_bytes < 1024 { - format!("RX: {:4} B", num_bytes).to_string() + format!("RX: {:5.*} B/s", 1, num_bytes as f64).to_string() } else if num_bytes < (1024 * 1024) { - format!("RX: {:4}KB", num_bytes / 1024).to_string() + format!("RX: {:5.*}KB/s", 1, num_bytes as f64 / 1024.0).to_string() } else if num_bytes < (1024 * 1024 * 1024) { - format!("RX: {:4}MB", num_bytes / 1024 / 1024).to_string() + format!("RX: {:5.*}MB/s", 1, num_bytes as f64 / 1024.0 / 1024.0).to_string() } else { - format!("RX: {:4}GB", num_bytes / 1024 / 1024 / 1024).to_string() + format!("RX: {:5.*}GB/s", 1, num_bytes as f64 / 1024.0 / 1024.0 / 1024.0).to_string() } } else { - "0B".to_string() + "0.0B/s".to_string() }; let tx_display = if let Some(last_num_bytes_entry) = network_data.last() { let num_bytes = last_num_bytes_entry.tx; if num_bytes < 1024 { - format!("TX: {:4} B", num_bytes).to_string() + format!("TX: {:5.*} B/s", 1, num_bytes as f64).to_string() } else if num_bytes < (1024 * 1024) { - format!("TX: {:4}KB", num_bytes / 1024).to_string() + format!("TX: {:5.*}KB/s", 1, num_bytes as f64 / 1024.0).to_string() } else if num_bytes < (1024 * 1024 * 1024) { - format!("TX: {:4}MB", num_bytes / 1024 / 1024).to_string() + format!("TX: {:5.*}MB/s", 1, num_bytes as f64 / 1024.0 / 1024.0).to_string() } else { - format!("TX: {:4}GB", num_bytes / 1024 / 1024 / 1024).to_string() + format!("TX: {:5.*}GB/s", 1, num_bytes as f64 / 1024.0 / 1024.0 / 1024.0).to_string() } } else { - "0B".to_string() + "0B.0/s".to_string() }; ConvertedNetworkData {