Struct sysinfo::NetworkData
source · pub struct NetworkData { /* private fields */ }Expand description
Getting volume of received and transmitted data.
use sysinfo::Networks;
let networks = Networks::new_with_refreshed_list();
for (interface_name, network) in &networks {
println!("[{interface_name}] {network:?}");
}Implementations§
source§impl NetworkData
impl NetworkData
sourcepub fn received(&self) -> u64
pub fn received(&self) -> u64
Returns the number of received bytes since the last refresh.
If you want the total number of bytes received, take a look at the
total_received method.
use sysinfo::Networks;
use std::{thread, time};
let mut networks = Networks::new_with_refreshed_list();
// Waiting a bit to get data from network...
thread::sleep(time::Duration::from_millis(10));
// Refreshing again to generate diff.
networks.refresh();
for (interface_name, network) in &networks {
println!("in: {} B", network.received());
}sourcepub fn total_received(&self) -> u64
pub fn total_received(&self) -> u64
Returns the total number of received bytes.
If you want the amount of received bytes since the last refresh, take a look at the
received method.
use sysinfo::Networks;
let networks = Networks::new_with_refreshed_list();
for (interface_name, network) in &networks {
println!("in: {} B", network.total_received());
}sourcepub fn transmitted(&self) -> u64
pub fn transmitted(&self) -> u64
Returns the number of transmitted bytes since the last refresh.
If you want the total number of bytes transmitted, take a look at the
total_transmitted method.
use sysinfo::Networks;
use std::{thread, time};
let mut networks = Networks::new_with_refreshed_list();
// Waiting a bit to get data from network...
thread::sleep(time::Duration::from_millis(10));
// Refreshing again to generate diff.
networks.refresh();
for (interface_name, network) in &networks {
println!("out: {} B", network.transmitted());
}sourcepub fn total_transmitted(&self) -> u64
pub fn total_transmitted(&self) -> u64
Returns the total number of transmitted bytes.
If you want the amount of transmitted bytes since the last refresh, take a look at the
transmitted method.
use sysinfo::Networks;
let networks = Networks::new_with_refreshed_list();
for (interface_name, network) in &networks {
println!("out: {} B", network.total_transmitted());
}sourcepub fn packets_received(&self) -> u64
pub fn packets_received(&self) -> u64
Returns the number of incoming packets since the last refresh.
If you want the total number of packets received, take a look at the
total_packets_received method.
use sysinfo::Networks;
use std::{thread, time};
let mut networks = Networks::new_with_refreshed_list();
// Waiting a bit to get data from network...
thread::sleep(time::Duration::from_millis(10));
// Refreshing again to generate diff.
networks.refresh();
for (interface_name, network) in &networks {
println!("in: {}", network.packets_received());
}sourcepub fn total_packets_received(&self) -> u64
pub fn total_packets_received(&self) -> u64
Returns the total number of incoming packets.
If you want the amount of received packets since the last refresh, take a look at the
packets_received method.
use sysinfo::Networks;
let networks = Networks::new_with_refreshed_list();
for (interface_name, network) in &networks {
println!("in: {}", network.total_packets_received());
}sourcepub fn packets_transmitted(&self) -> u64
pub fn packets_transmitted(&self) -> u64
Returns the number of outcoming packets since the last refresh.
If you want the total number of packets transmitted, take a look at the
total_packets_transmitted method.
use sysinfo::Networks;
use std::{thread, time};
let mut networks = Networks::new_with_refreshed_list();
// Waiting a bit to get data from network...
thread::sleep(time::Duration::from_millis(10));
// Refreshing again to generate diff.
networks.refresh();
for (interface_name, network) in &networks {
println!("out: {}", network.packets_transmitted());
}sourcepub fn total_packets_transmitted(&self) -> u64
pub fn total_packets_transmitted(&self) -> u64
Returns the total number of outcoming packets.
If you want the amount of transmitted packets since the last refresh, take a look at the
packets_transmitted method.
use sysinfo::Networks;
let networks = Networks::new_with_refreshed_list();
for (interface_name, network) in &networks {
println!("out: {}", network.total_packets_transmitted());
}sourcepub fn errors_on_received(&self) -> u64
pub fn errors_on_received(&self) -> u64
Returns the number of incoming errors since the last refresh.
If you want the total number of errors on received packets, take a look at the
total_errors_on_received method.
use sysinfo::Networks;
use std::{thread, time};
let mut networks = Networks::new_with_refreshed_list();
// Waiting a bit to get data from network...
thread::sleep(time::Duration::from_millis(10));
// Refreshing again to generate diff.
networks.refresh();
for (interface_name, network) in &networks {
println!("in: {}", network.errors_on_received());
}sourcepub fn total_errors_on_received(&self) -> u64
pub fn total_errors_on_received(&self) -> u64
Returns the total number of incoming errors.
If you want the amount of errors on received packets since the last refresh, take a look at
the errors_on_received method.
use sysinfo::Networks;
let networks = Networks::new_with_refreshed_list();
for (interface_name, network) in &networks {
println!("in: {}", network.total_errors_on_received());
}sourcepub fn errors_on_transmitted(&self) -> u64
pub fn errors_on_transmitted(&self) -> u64
Returns the number of outcoming errors since the last refresh.
If you want the total number of errors on transmitted packets, take a look at the
total_errors_on_transmitted method.
use sysinfo::Networks;
use std::{thread, time};
let mut networks = Networks::new_with_refreshed_list();
// Waiting a bit to get data from network...
thread::sleep(time::Duration::from_millis(10));
// Refreshing again to generate diff.
networks.refresh();
for (interface_name, network) in &networks {
println!("out: {}", network.errors_on_transmitted());
}sourcepub fn total_errors_on_transmitted(&self) -> u64
pub fn total_errors_on_transmitted(&self) -> u64
Returns the total number of outcoming errors.
If you want the amount of errors on transmitted packets since the last refresh, take a look at
the errors_on_transmitted method.
use sysinfo::Networks;
let networks = Networks::new_with_refreshed_list();
for (interface_name, network) in &networks {
println!("out: {}", network.total_errors_on_transmitted());
}sourcepub fn mac_address(&self) -> MacAddr
pub fn mac_address(&self) -> MacAddr
Returns the MAC address associated to current interface.
use sysinfo::Networks;
let mut networks = Networks::new_with_refreshed_list();
for (interface_name, network) in &networks {
println!("MAC address: {}", network.mac_address());
}sourcepub fn ip_networks(&self) -> &[IpNetwork]
pub fn ip_networks(&self) -> &[IpNetwork]
Returns the Ip Networks associated to current interface.
use sysinfo::Networks;
let mut networks = Networks::new_with_refreshed_list();
for (interface_name, network) in &networks {
println!("Ip Networks: {:?}", network.ip_networks());
}Trait Implementations§
source§impl Debug for NetworkData
impl Debug for NetworkData
Auto Trait Implementations§
impl Freeze for NetworkData
impl RefUnwindSafe for NetworkData
impl Send for NetworkData
impl Sync for NetworkData
impl Unpin for NetworkData
impl UnwindSafe for NetworkData
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T, U> Into<U> for Twhere
U: From<T>,
impl<T, U> Into<U> for Twhere
U: From<T>,
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>where
F: FnOnce(&Self) -> bool,
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>where
F: FnOnce(&Self) -> bool,
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more