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).
Methods
impl Interface[src]
impl Interfacepub fn get_all() -> Result<Vec<Interface>>[src]
pub fn get_all() -> Result<Vec<Interface>>Retrieve a list of all interfaces on this system.
pub fn get_by_name(name: &str) -> Result<Option<Interface>>[src]
pub fn get_by_name(name: &str) -> Result<Option<Interface>>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 = try!(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]
pub fn is_up(&self) -> boolReturns whether this interface is up.
pub fn is_loopback(&self) -> bool[src]
pub fn is_loopback(&self) -> boolReturns whether this interface is a loopback address.
pub fn hardware_addr(&self) -> Result<HardwareAddr>[src]
pub fn hardware_addr(&self) -> Result<HardwareAddr>Retrieves the hardware address of this interface.
pub fn set_up(&mut self, up: bool) -> Result<()>[src]
pub fn set_up(&mut self, up: bool) -> Result<()>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]
pub fn get_mtu(&self) -> Result<u32>Retrieve the MTU of this interface.
Trait Implementations
impl Debug for Interface[src]
impl Debug for Interfacefn fmt(&self, f: &mut Formatter) -> Result[src]
fn fmt(&self, f: &mut Formatter) -> ResultFormats the value using the given formatter. Read more
impl PartialEq for Interface[src]
impl PartialEq for Interfacefn eq(&self, other: &Interface) -> bool[src]
fn eq(&self, other: &Interface) -> boolThis method tests for self and other values to be equal, and is used by ==. Read more
#[must_use]
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn ne(&self, other: &Rhs) -> boolThis method tests for !=.
impl Eq for Interface[src]
impl Eq for Interfaceimpl Drop for Interface[src]
impl Drop for Interface