| 1 | use craterust-analyzer cargo bottom 0.14.9 crate/::{collectionrust-analyzer cargo bottom 0.14.9 collection/::networkrust-analyzer cargo bottom 0.14.9 collection/network/::NetworkHarvestrust-analyzer cargo bottom 0.14.9 collection/network/NetworkHarvest#, utilsrust-analyzer cargo bottom 0.14.9 utils/::data_unitsrust-analyzer cargo bottom 0.14.9 utils/data_units/::convert_bytesrust-analyzer cargo bottom 0.14.9 utils/data_units/convert_bytes().}; |
| 2 | |
| 3 | pub mod cpu_basicrust-analyzer cargo bottom 0.14.9 canvas/widgets/cpu_basic/; |
| 4 | pub mod cpu_graphrust-analyzer cargo bottom 0.14.9 canvas/widgets/cpu_graph/; |
| 5 | pub mod disk_io_graphrust-analyzer cargo bottom 0.14.9 canvas/widgets/disk_io_graph/; |
| 6 | pub mod disk_tablerust-analyzer cargo bottom 0.14.9 canvas/widgets/disk_table/; |
| 7 | pub mod mem_basicrust-analyzer cargo bottom 0.14.9 canvas/widgets/mem_basic/; |
| 8 | pub mod mem_graphrust-analyzer cargo bottom 0.14.9 canvas/widgets/mem_graph/; |
| 9 | pub mod network_basicrust-analyzer cargo bottom 0.14.9 canvas/widgets/network_basic/; |
| 10 | pub mod network_graphrust-analyzer cargo bottom 0.14.9 canvas/widgets/network_graph/; |
| 11 | pub mod process_tablerust-analyzer cargo bottom 0.14.9 canvas/widgets/process_table/; |
| 12 | pub mod temperature_graphrust-analyzer cargo bottom 0.14.9 canvas/widgets/temperature_graph/; |
| 13 | pub mod temperature_tablerust-analyzer cargo bottom 0.14.9 canvas/widgets/temperature_table/; |
| 14 | |
| 15 | #[cfg(feature = "battery")] |
| 16 | pub mod battery_displayrust-analyzer cargo bottom 0.14.9 canvas/widgets/battery_display/; |
| 17 | |
| 18 | /// Helper struct to hold packet-related data |
| 19 | pub(superrust-analyzer cargo bottom 0.14.9 canvas/) struct PacketInforust-analyzer cargo bottom 0.14.9 canvas/widgets/PacketInfo# { |
| 20 | /// Current received packet rate. |
| 21 | pub(superrust-analyzer cargo bottom 0.14.9 canvas/) rx_packet_raterust-analyzer cargo bottom 0.14.9 canvas/widgets/PacketInfo#rx_packet_rate.: u64, |
| 22 | |
| 23 | /// Current transmitted packet rate. |
| 24 | pub(superrust-analyzer cargo bottom 0.14.9 canvas/) tx_packet_raterust-analyzer cargo bottom 0.14.9 canvas/widgets/PacketInfo#tx_packet_rate.: u64, |
| 25 | |
| 26 | /// Average received packet size in bytes, converted to the nearest unit. |
| 27 | pub(superrust-analyzer cargo bottom 0.14.9 canvas/) avg_rx_packet_sizerust-analyzer cargo bottom 0.14.9 canvas/widgets/PacketInfo#avg_rx_packet_size.: (f64, &'static str), |
| 28 | |
| 29 | /// Average transmitted packet size in bytes, converted to the nearest unit. |
| 30 | pub(superrust-analyzer cargo bottom 0.14.9 canvas/) avg_tx_packet_sizerust-analyzer cargo bottom 0.14.9 canvas/widgets/PacketInfo#avg_tx_packet_size.: (f64, &'static str), |
| 31 | } |
| 32 | |
| 33 | /// Calculate packet information from network data. |
| 34 | pub(superrust-analyzer cargo bottom 0.14.9 canvas/) fn calculate_packet_inforust-analyzer cargo bottom 0.14.9 canvas/widgets/calculate_packet_info().( |
| 35 | network_latest_data: &NetworkHarvestrust-analyzer cargo bottom 0.14.9 collection/network/NetworkHarvest#, use_binary_prefix: bool, |
| 36 | ) -> PacketInforust-analyzer cargo bottom 0.14.9 canvas/widgets/PacketInfo# { |
| 37 | let rx_packet_rate = network_latest_data.rx_packetsrust-analyzer cargo bottom 0.14.9 collection/network/NetworkHarvest#rx_packets.; |
| 38 | let tx_packet_rate = network_latest_data.tx_packetsrust-analyzer cargo bottom 0.14.9 collection/network/NetworkHarvest#tx_packets.; |
| 39 | |
| 40 | // Calculate average packet size (bytes per packet) |
| 41 | let avg_rx_packet_size = if network_latest_data.rx_packetsrust-analyzer cargo bottom 0.14.9 collection/network/NetworkHarvest#rx_packets. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt().0 { |
| 42 | (network_latest_data.rxrust-analyzer cargo bottom 0.14.9 collection/network/NetworkHarvest#rx. as f64 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().8.0) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().network_latest_data.rx_packetsrust-analyzer cargo bottom 0.14.9 collection/network/NetworkHarvest#rx_packets. as f64 // Convert bits to bytes |
| 43 | } else { |
| 44 | 0.0 |
| 45 | }; |
| 46 | |
| 47 | let avg_tx_packet_size = if network_latest_data.tx_packetsrust-analyzer cargo bottom 0.14.9 collection/network/NetworkHarvest#tx_packets. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt().0 { |
| 48 | (network_latest_data.txrust-analyzer cargo bottom 0.14.9 collection/network/NetworkHarvest#tx. as f64 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().8.0) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().network_latest_data.tx_packetsrust-analyzer cargo bottom 0.14.9 collection/network/NetworkHarvest#tx_packets. as f64 // Convert bits to bytes |
| 49 | } else { |
| 50 | 0.0 |
| 51 | }; |
| 52 | |
| 53 | let avg_rx_packet_size = convert_bytesrust-analyzer cargo bottom 0.14.9 utils/data_units/convert_bytes().(avg_rx_packet_size.roundrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]round().() as u64, use_binary_prefix); |
| 54 | let avg_tx_packet_size = convert_bytesrust-analyzer cargo bottom 0.14.9 utils/data_units/convert_bytes().(avg_tx_packet_size.roundrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]round().() as u64, use_binary_prefix); |
| 55 | |
| 56 | PacketInforust-analyzer cargo bottom 0.14.9 canvas/widgets/PacketInfo# { |
| 57 | rx_packet_raterust-analyzer cargo bottom 0.14.9 canvas/widgets/PacketInfo#rx_packet_rate., |
| 58 | tx_packet_raterust-analyzer cargo bottom 0.14.9 canvas/widgets/PacketInfo#tx_packet_rate., |
| 59 | avg_rx_packet_sizerust-analyzer cargo bottom 0.14.9 canvas/widgets/PacketInfo#avg_rx_packet_size., |
| 60 | avg_tx_packet_sizerust-analyzer cargo bottom 0.14.9 canvas/widgets/PacketInfo#avg_tx_packet_size., |
| 61 | } |
| 62 | } |