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]
fn get_all() -> Result<Vec<Interface>>
Retrieve a list of all interfaces on this system.
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"); }
fn is_up(&self) -> bool
Returns whether this interface is up.
fn is_loopback(&self) -> bool
Returns whether this interface is a loopback address.
fn hardware_addr(&self) -> Result<HardwareAddr>
Retrieves the hardware address of this interface.
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.
fn get_mtu(&self) -> Result<u32>
Retrieve the MTU of this interface.
Trait Implementations
impl Debug for Interface
[src]
impl PartialEq for Interface
[src]
fn eq(&self, other: &Interface) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0
This method tests for !=
.