Trait sysinfo::NetworkExt
source · pub trait NetworkExt: Debug {
Show 13 methods
// Required methods
fn received(&self) -> u64;
fn total_received(&self) -> u64;
fn transmitted(&self) -> u64;
fn total_transmitted(&self) -> u64;
fn packets_received(&self) -> u64;
fn total_packets_received(&self) -> u64;
fn packets_transmitted(&self) -> u64;
fn total_packets_transmitted(&self) -> u64;
fn errors_on_received(&self) -> u64;
fn total_errors_on_received(&self) -> u64;
fn errors_on_transmitted(&self) -> u64;
fn total_errors_on_transmitted(&self) -> u64;
fn mac_address(&self) -> MacAddr;
}
Expand description
Getting volume of received and transmitted data.
Required Methods§
sourcefn received(&self) -> u64
fn received(&self) -> u64
Returns the number of received bytes since the last refresh.
use sysinfo::{NetworkExt, NetworksExt, System, SystemExt};
let s = System::new_all();
let networks = s.networks();
for (interface_name, network) in networks {
println!("in: {} B", network.received());
}
sourcefn total_received(&self) -> u64
fn total_received(&self) -> u64
Returns the total number of received bytes.
use sysinfo::{NetworkExt, NetworksExt, System, SystemExt};
let s = System::new_all();
let networks = s.networks();
for (interface_name, network) in networks {
println!("in: {} B", network.total_received());
}
sourcefn transmitted(&self) -> u64
fn transmitted(&self) -> u64
Returns the number of transmitted bytes since the last refresh.
use sysinfo::{NetworkExt, NetworksExt, System, SystemExt};
let s = System::new_all();
let networks = s.networks();
for (interface_name, network) in networks {
println!("out: {} B", network.transmitted());
}
sourcefn total_transmitted(&self) -> u64
fn total_transmitted(&self) -> u64
Returns the total number of transmitted bytes.
use sysinfo::{NetworkExt, NetworksExt, System, SystemExt};
let s = System::new_all();
let networks = s.networks();
for (interface_name, network) in networks {
println!("out: {} B", network.total_transmitted());
}
sourcefn packets_received(&self) -> u64
fn packets_received(&self) -> u64
Returns the number of incoming packets since the last refresh.
use sysinfo::{NetworkExt, NetworksExt, System, SystemExt};
let s = System::new_all();
let networks = s.networks();
for (interface_name, network) in networks {
println!("in: {}", network.packets_received());
}
sourcefn total_packets_received(&self) -> u64
fn total_packets_received(&self) -> u64
Returns the total number of incoming packets.
use sysinfo::{NetworkExt, NetworksExt, System, SystemExt};
let s = System::new_all();
let networks = s.networks();
for (interface_name, network) in networks {
println!("in: {}", network.total_packets_received());
}
sourcefn packets_transmitted(&self) -> u64
fn packets_transmitted(&self) -> u64
Returns the number of outcoming packets since the last refresh.
use sysinfo::{NetworkExt, NetworksExt, System, SystemExt};
let s = System::new_all();
let networks = s.networks();
for (interface_name, network) in networks {
println!("out: {}", network.packets_transmitted());
}
sourcefn total_packets_transmitted(&self) -> u64
fn total_packets_transmitted(&self) -> u64
Returns the total number of outcoming packets.
use sysinfo::{NetworkExt, NetworksExt, System, SystemExt};
let s = System::new_all();
let networks = s.networks();
for (interface_name, network) in networks {
println!("out: {}", network.total_packets_transmitted());
}
sourcefn errors_on_received(&self) -> u64
fn errors_on_received(&self) -> u64
Returns the number of incoming errors since the last refresh.
use sysinfo::{NetworkExt, NetworksExt, System, SystemExt};
let s = System::new_all();
let networks = s.networks();
for (interface_name, network) in networks {
println!("in: {}", network.errors_on_received());
}
sourcefn total_errors_on_received(&self) -> u64
fn total_errors_on_received(&self) -> u64
Returns the total number of incoming errors.
use sysinfo::{NetworkExt, NetworksExt, System, SystemExt};
let s = System::new_all();
let networks = s.networks();
for (interface_name, network) in networks {
println!("in: {}", network.total_errors_on_received());
}
sourcefn errors_on_transmitted(&self) -> u64
fn errors_on_transmitted(&self) -> u64
Returns the number of outcoming errors since the last refresh.
use sysinfo::{NetworkExt, NetworksExt, System, SystemExt};
let s = System::new_all();
let networks = s.networks();
for (interface_name, network) in networks {
println!("out: {}", network.errors_on_transmitted());
}
sourcefn total_errors_on_transmitted(&self) -> u64
fn total_errors_on_transmitted(&self) -> u64
Returns the total number of outcoming errors.
use sysinfo::{NetworkExt, NetworksExt, System, SystemExt};
let s = System::new_all();
let networks = s.networks();
for (interface_name, network) in networks {
println!("out: {}", network.total_errors_on_transmitted());
}
sourcefn mac_address(&self) -> MacAddr
fn mac_address(&self) -> MacAddr
Returns the MAC address associated to current interface.
use sysinfo::{NetworkExt, NetworksExt, System, SystemExt};
let s = System::new_all();
let networks = s.networks();
for (interface_name, network) in networks {
println!("MAC address: {}", network.mac_address());
}