Struct mprober_lib::network::NetworkStat
source · [−]Fields
receive_bytes: u64transmit_bytes: u64Implementations
sourceimpl 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.
extern crate mprober_lib;
use std::thread::sleep;
use std::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
sourceimpl Clone for NetworkStat
impl Clone for NetworkStat
sourcefn clone(&self) -> NetworkStat
fn clone(&self) -> NetworkStat
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
sourceimpl Debug for NetworkStat
impl Debug for NetworkStat
sourceimpl Default for NetworkStat
impl Default for NetworkStat
sourcefn default() -> NetworkStat
fn default() -> NetworkStat
Returns the “default value” for a type. Read more
sourceimpl PartialEq<NetworkStat> for NetworkStat
impl PartialEq<NetworkStat> for NetworkStat
sourcefn 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 ==. Read more
sourcefn ne(&self, other: &NetworkStat) -> bool
fn ne(&self, other: &NetworkStat) -> bool
This method tests for !=.
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more