[][src]Struct mprober_lib::network::NetworkStat

pub struct NetworkStat {
    pub receive_bytes: u64,
    pub transmit_bytes: u64,
}

Fields

receive_bytes: u64transmit_bytes: u64

Implementations

impl NetworkStat[src]

pub fn compute_speed(
    &self,
    network_stat_after_this: &NetworkStat,
    interval: Duration
) -> NetworkSpeed
[src]

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

impl Clone for NetworkStat[src]

impl Debug for NetworkStat[src]

impl Default for NetworkStat[src]

impl Eq for NetworkStat[src]

impl PartialEq<NetworkStat> for NetworkStat[src]

impl StructuralEq for NetworkStat[src]

impl StructuralPartialEq for NetworkStat[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.