#[non_exhaustive]pub struct Interface {Show 18 fields
pub index: u32,
pub name: String,
pub friendly_name: Option<String>,
pub description: Option<String>,
pub if_type: InterfaceType,
pub mac_addr: Option<MacAddr>,
pub ipv4: Vec<Ipv4Net>,
pub ipv6: Vec<Ipv6Net>,
pub ipv6_scope_ids: Vec<u32>,
pub flags: u32,
pub oper_state: OperState,
pub transmit_speed: Option<u64>,
pub receive_speed: Option<u64>,
pub stats: Option<InterfaceStats>,
pub gateway: Option<NetworkDevice>,
pub dns_servers: Vec<IpAddr>,
pub mtu: Option<u32>,
pub default: bool,
}Expand description
A network interface.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.index: u32Operating-system interface index.
name: StringOperating-system interface name.
friendly_name: Option<String>User-facing interface name when supplied by the platform.
description: Option<String>Platform-provided interface description.
if_type: InterfaceTypeClassified interface hardware or transport type.
mac_addr: Option<MacAddr>Link-layer address, when one is available.
ipv4: Vec<Ipv4Net>Assigned IPv4 networks.
ipv6: Vec<Ipv6Net>Assigned IPv6 networks.
ipv6_scope_ids: Vec<u32>Scope identifiers corresponding to scoped IPv6 addresses.
flags: u32Raw platform interface flags.
oper_state: OperStateCurrent operational state.
transmit_speed: Option<u64>Reported transmit speed in bits per second.
receive_speed: Option<u64>Reported receive speed in bits per second.
stats: Option<InterfaceStats>Most recently sampled traffic statistics.
gateway: Option<NetworkDevice>Default gateway reachable through this interface.
dns_servers: Vec<IpAddr>DNS servers associated with this interface.
mtu: Option<u32>Maximum transmission unit in bytes.
default: boolWhether this is the platform’s default interface.
Implementations§
Source§impl Interface
impl Interface
pub fn default() -> Result<Interface, InterfaceError>
pub fn dummy() -> Interface
Sourcepub fn refresh(&mut self) -> Result<()>
pub fn refresh(&mut self) -> Result<()>
Refresh all interface fields from the operating system.
This performs a fresh system lookup and may be more expensive than
the accessor methods on Interface.
pub fn is_up(&self) -> bool
pub fn is_loopback(&self) -> bool
pub fn is_point_to_point(&self) -> bool
pub fn is_multicast(&self) -> bool
pub fn is_broadcast(&self) -> bool
pub fn is_tun(&self) -> bool
pub fn is_running(&self) -> bool
pub fn is_physical(&self) -> bool
pub fn oper_state(&self) -> OperState
pub fn is_oper_up(&self) -> bool
Sourcepub fn refresh_oper_state(&mut self) -> Result<()>
pub fn refresh_oper_state(&mut self) -> Result<()>
Refresh the operational state from the operating system.
This may perform a fresh interface lookup.
Sourcepub fn update_oper_state(&mut self)
pub fn update_oper_state(&mut self)
Refresh the operational state from the operating system.
This may perform a fresh interface lookup.
Sourcepub fn ipv4_addr_iter(&self) -> impl Iterator<Item = Ipv4Addr> + '_
pub fn ipv4_addr_iter(&self) -> impl Iterator<Item = Ipv4Addr> + '_
Iterate IPv4 addresses without allocating a new vector.
pub fn ipv4_addrs(&self) -> Vec<Ipv4Addr>
Sourcepub fn ipv6_addr_iter(&self) -> impl Iterator<Item = Ipv6Addr> + '_
pub fn ipv6_addr_iter(&self) -> impl Iterator<Item = Ipv6Addr> + '_
Iterate IPv6 addresses without allocating a new vector.
pub fn ipv6_addrs(&self) -> Vec<Ipv6Addr>
Sourcepub fn ip_addr_iter(&self) -> impl Iterator<Item = IpAddr> + '_
pub fn ip_addr_iter(&self) -> impl Iterator<Item = IpAddr> + '_
Iterate IP addresses without allocating a new vector.
pub fn ip_addrs(&self) -> Vec<IpAddr>
pub fn has_ipv4(&self) -> bool
pub fn has_ipv6(&self) -> bool
pub fn has_global_ipv4(&self) -> bool
pub fn has_global_ipv6(&self) -> bool
pub fn has_global_ip(&self) -> bool
pub fn global_ipv4_addrs(&self) -> Vec<Ipv4Addr>
pub fn global_ipv6_addrs(&self) -> Vec<Ipv6Addr>
pub fn global_ip_addrs(&self) -> Vec<IpAddr>
Sourcepub fn refresh_stats(&mut self) -> Result<()>
pub fn refresh_stats(&mut self) -> Result<()>
Refresh interface statistics from the operating system.
This may perform a fresh interface lookup.
Sourcepub fn update_stats(&mut self) -> Result<()>
pub fn update_stats(&mut self) -> Result<()>
Refresh interface statistics from the operating system.
This may perform a fresh interface lookup.