Struct mprober_lib::network::NetworkStat
source · pub struct NetworkStat {
pub receive_bytes: u64,
pub transmit_bytes: u64,
}Fields§
§receive_bytes: u64§transmit_bytes: u64Implementations§
source§impl NetworkStat
impl NetworkStat
sourcepub fn compute_speed(
&self,
network_stat_after_this: &NetworkStat,
interval: Duration
) -> NetworkSpeed
pub fn compute_speed( &self, network_stat_after_this: &NetworkStat, interval: Duration ) -> NetworkSpeed
Calculate speed between two NetworkStat instances at different time.
use std::{thread::sleep, time::Duration};
use mprober_lib::network;
let pre_networks = network::get_networks().unwrap();
let interval = Duration::from_millis(100);
sleep(interval);
let networks = network::get_networks().unwrap();
if !pre_networks.is_empty() && !networks.is_empty() {
let network_speed =
pre_networks[0].stat.compute_speed(&networks[0].stat, interval);
println!("Receive: {:.1} B/s", network_speed.receive);
println!("Transmit: {:.1} B/s", network_speed.transmit);
}Trait Implementations§
source§impl Clone for NetworkStat
impl Clone for NetworkStat
source§fn clone(&self) -> NetworkStat
fn clone(&self) -> NetworkStat
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl Debug for NetworkStat
impl Debug for NetworkStat
source§impl Default for NetworkStat
impl Default for NetworkStat
source§fn default() -> NetworkStat
fn default() -> NetworkStat
Returns the “default value” for a type. Read more
source§impl PartialEq for NetworkStat
impl PartialEq for NetworkStat
source§fn eq(&self, other: &NetworkStat) -> bool
fn eq(&self, other: &NetworkStat) -> bool
This method tests for
self and other values to be equal, and is used
by ==.impl Eq for NetworkStat
impl StructuralEq for NetworkStat
impl StructuralPartialEq for NetworkStat
Auto Trait Implementations§
impl RefUnwindSafe for NetworkStat
impl Send for NetworkStat
impl Sync for NetworkStat
impl Unpin for NetworkStat
impl UnwindSafe for NetworkStat
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more