Struct Net

Source
pub struct Net { /* private fields */ }

Implementations§

Source§

impl Net

Source

pub fn statistics(&self) -> NetStatistics<'_>

Examples found in repository?
examples/net.rs (line 12)
4fn main() -> io::Result<()> {
5    for dev in Net::iter() {
6        let dev = dev?;
7
8        println!("{}: {}", dev.id(), dev.address().unwrap());
9        println!("    MTU: {}", dev.mtu().unwrap());
10        println!("    Duplex: {:?}", dev.duplex());
11
12        let statistics = dev.statistics();
13        println!(
14            "    RX: {} MiB",
15            statistics.rx_bytes().unwrap() / (1024 * 1024)
16        );
17        println!(
18            "    TX: {} MiB",
19            statistics.tx_bytes().unwrap() / (1024 * 1024)
20        );
21    }
22
23    Ok(())
24}
Source

pub fn addr_assign_type(&self) -> Result<u8>

Source

pub fn addr_len(&self) -> Result<u16>

Source

pub fn address(&self) -> Result<String>

Examples found in repository?
examples/net.rs (line 8)
4fn main() -> io::Result<()> {
5    for dev in Net::iter() {
6        let dev = dev?;
7
8        println!("{}: {}", dev.id(), dev.address().unwrap());
9        println!("    MTU: {}", dev.mtu().unwrap());
10        println!("    Duplex: {:?}", dev.duplex());
11
12        let statistics = dev.statistics();
13        println!(
14            "    RX: {} MiB",
15            statistics.rx_bytes().unwrap() / (1024 * 1024)
16        );
17        println!(
18            "    TX: {} MiB",
19            statistics.tx_bytes().unwrap() / (1024 * 1024)
20        );
21    }
22
23    Ok(())
24}
Source

pub fn broadcast(&self) -> Result<String>

Source

pub fn carrier(&self) -> Result<u16>

Source

pub fn carrier_changes(&self) -> Result<u16>

Source

pub fn carrier_down_count(&self) -> Result<u16>

Source

pub fn carrier_up_count(&self) -> Result<u16>

Source

pub fn dev_id(&self) -> Result<String>

Source

pub fn dev_port(&self) -> Result<u16>

Source

pub fn dormant(&self) -> Result<u8>

Source

pub fn duplex(&self) -> Result<String>

Examples found in repository?
examples/net.rs (line 10)
4fn main() -> io::Result<()> {
5    for dev in Net::iter() {
6        let dev = dev?;
7
8        println!("{}: {}", dev.id(), dev.address().unwrap());
9        println!("    MTU: {}", dev.mtu().unwrap());
10        println!("    Duplex: {:?}", dev.duplex());
11
12        let statistics = dev.statistics();
13        println!(
14            "    RX: {} MiB",
15            statistics.rx_bytes().unwrap() / (1024 * 1024)
16        );
17        println!(
18            "    TX: {} MiB",
19            statistics.tx_bytes().unwrap() / (1024 * 1024)
20        );
21    }
22
23    Ok(())
24}
Source

pub fn mtu(&self) -> Result<u32>

Examples found in repository?
examples/net.rs (line 9)
4fn main() -> io::Result<()> {
5    for dev in Net::iter() {
6        let dev = dev?;
7
8        println!("{}: {}", dev.id(), dev.address().unwrap());
9        println!("    MTU: {}", dev.mtu().unwrap());
10        println!("    Duplex: {:?}", dev.duplex());
11
12        let statistics = dev.statistics();
13        println!(
14            "    RX: {} MiB",
15            statistics.rx_bytes().unwrap() / (1024 * 1024)
16        );
17        println!(
18            "    TX: {} MiB",
19            statistics.tx_bytes().unwrap() / (1024 * 1024)
20        );
21    }
22
23    Ok(())
24}
Source

pub fn operstate(&self) -> Result<String>

Source

pub fn speed(&self) -> Result<u32>

Source

pub fn tx_queue_len(&self) -> Result<u32>

Trait Implementations§

Source§

impl Clone for Net

Source§

fn clone(&self) -> Net

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl SysClass for Net

Source§

fn class() -> &'static str

Return the class of the sys object, the name of a folder in `/sys/${base}``
Source§

unsafe fn from_path_unchecked(path: PathBuf) -> Self

Create a sys object from an absolute path without checking path for validity
Source§

fn path(&self) -> &Path

Return the path of the sys object
Source§

fn base() -> &'static str

Sets the base directory, which defaults to class.
Source§

fn dir() -> PathBuf

Return the path to the sys objects, the full path of a folder in /sys/class
Source§

fn from_path(path: &Path) -> Result<Self>

Create a sys object from a path, checking it for validity
Source§

fn all() -> Result<Vec<Self>>

Retrieve all of the object instances of a sys class
Source§

fn iter() -> Box<dyn Iterator<Item = Result<Self>>>
where Self: 'static,

Retrieve all of the object instances of a sys class, with a boxed iterator
Source§

fn new(id: &str) -> Result<Self>

Create a sys object by id, checking it for validity
Source§

fn id(&self) -> &str

Return the id of the sys object
Source§

fn read_file<P: AsRef<Path>>(&self, name: P) -> Result<String>

Read a file underneath the sys object
Source§

fn parse_file<F: FromStr, P: AsRef<Path>>(&self, name: P) -> Result<F>
where F::Err: Display,

Parse a number from a file underneath the sys object
Source§

fn trim_file<P: AsRef<Path>>(&self, name: P) -> Result<String>

Read a file underneath the sys object and trim whitespace
Source§

fn write_file<P: AsRef<Path>, S: AsRef<[u8]>>( &self, name: P, data: S, ) -> Result<()>

Write a file underneath the sys object

Auto Trait Implementations§

§

impl Freeze for Net

§

impl RefUnwindSafe for Net

§

impl Send for Net

§

impl Sync for Net

§

impl Unpin for Net

§

impl UnwindSafe for Net

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.