pub struct Interface(/* private fields */);
Expand description
Wrapped interface index.
Index is chosen, because basically all operating systems use index as an identifier. This struct can be used to manipulate interface parameters, such as IP address and MTU.
Implementations§
Source§impl Interface
impl Interface
Sourcepub fn remove_address(&self, network: IpNet) -> Result<(), Error>
pub fn remove_address(&self, network: IpNet) -> Result<(), Error>
Remove the specified address from the interface
Sourcepub fn addresses(&self) -> Result<Vec<IpNet>, Error>
pub fn addresses(&self) -> Result<Vec<IpNet>, Error>
Returns list of IP addresses, assigned to this Interface
pub fn mtu(&self) -> Result<u32, Error>
pub fn set_mtu(&self, mtu: u32) -> Result<(), Error>
pub fn name(&self) -> Result<String, Error>
pub fn index(&self) -> Result<u32, Error>
Sourcepub fn hwaddress(&self) -> Result<[u8; 6], Error>
pub fn hwaddress(&self) -> Result<[u8; 6], Error>
Returns MAC address, assigned to this Interface
Sourcepub unsafe fn from_index_unchecked(index: u32) -> Self
pub unsafe fn from_index_unchecked(index: u32) -> Self
§Safety
The passed interface index must be valid
Sourcepub fn try_from_index(index: u32) -> Result<Self, Error>
pub fn try_from_index(index: u32) -> Result<Self, Error>
Returns InterfaceHandle
from given interface index or Error if not found.
This method checks given index for validity and interface for presence. If you want to get
InterfaceHandle
without checking interface for presence, use from_index_unchecked
.
Sourcepub fn try_from_name(name: &str) -> Result<Self, Error>
pub fn try_from_name(name: &str) -> Result<Self, Error>
Returns InterfaceHandle
from given name or Error if not found.
On Windows it uses interface name, that is similar to ethernet_32774
.
If you want to search interface by human-readable name (like Ethernet 1
), use try_from_alias