Struct interfaces::Interface[][src]

pub struct Interface {
    pub name: String,
    pub addresses: Vec<Address>,
    pub flags: InterfaceFlags,
    // some fields omitted
}

The Interface structure represents a single interface on the system. It also contains methods to control the interface.

Fields

name: String

The name of this interface.

addresses: Vec<Address>

All addresses for this interface.

flags: InterfaceFlags

Interface flags.

NOTE: The underlying API returns this value for each address of an interface, not each interface itself. We assume that they are all equal and take the first set of flags (from the first address).

Implementations

impl Interface[src]

pub fn get_all() -> Result<Vec<Interface>>[src]

Retrieve a list of all interfaces on this system.

pub fn get_by_name(name: &str) -> Result<Option<Interface>>[src]

Returns an Interface instance representing the interface with the given name. Will return Ok(Some(Interface)) on success, Ok(None) if there is no such interface, and Err(..) on failure.

let iface = Interface::get_by_name("lo")?;
if let Some(ref lo) = iface {
    assert!(lo.is_loopback());
} else {
    println!("Could not find loopback interface");
}

pub fn is_up(&self) -> bool[src]

Returns whether this interface is up.

pub fn is_running(&self) -> bool[src]

Returns whether this interface is ready for transfer.

pub fn is_loopback(&self) -> bool[src]

Returns whether this interface is a loopback address.

pub fn hardware_addr(&self) -> Result<HardwareAddr>[src]

Retrieves the hardware address of this interface.

pub fn set_up(&mut self, up: bool) -> Result<()>[src]

Sets the interface as up or down. This will change the status of the given interface in the system, and update the flags of this Interface instance.

pub fn get_mtu(&self) -> Result<u32>[src]

Retrieve the MTU of this interface.

Trait Implementations

impl Debug for Interface[src]

impl Drop for Interface[src]

impl Eq for Interface[src]

impl PartialEq<Interface> for Interface[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, 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.