#[non_exhaustive]pub struct Interface {
pub id: InterfaceId,
pub name: String,
pub interface_type: InterfaceType,
pub is_up: bool,
pub addresses: Vec<IpAddr>,
pub mac: Option<[u8; 6]>,
pub signal_strength: Option<u8>,
pub link_speed_mbps: Option<u32>,
pub is_metered: bool,
}Expand description
Network interface descriptor.
Tier: T2-C (Σ + μ + ∃ + ς — typed, mapped, existent, stateful)
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.id: InterfaceIdUnique interface ID.
name: StringHuman-readable name (e.g., “wlan0”, “eth0”).
interface_type: InterfaceTypeInterface type.
is_up: boolWhether the interface is currently up.
addresses: Vec<IpAddr>Assigned IP addresses.
mac: Option<[u8; 6]>Hardware (MAC) address, if available.
signal_strength: Option<u8>Signal strength (0-100), if applicable.
link_speed_mbps: Option<u32>Link speed in Mbps, if known.
is_metered: boolWhether this interface is metered.
Implementations§
Source§impl Interface
impl Interface
Sourcepub fn new(
id: impl Into<String>,
name: impl Into<String>,
interface_type: InterfaceType,
) -> Self
pub fn new( id: impl Into<String>, name: impl Into<String>, interface_type: InterfaceType, ) -> Self
Create a new interface.
Sourcepub fn with_address(self, addr: IpAddr) -> Self
pub fn with_address(self, addr: IpAddr) -> Self
Builder: add an IP address.
Sourcepub fn with_signal(self, strength: u8) -> Self
pub fn with_signal(self, strength: u8) -> Self
Builder: set signal strength.
Sourcepub fn with_speed(self, mbps: u32) -> Self
pub fn with_speed(self, mbps: u32) -> Self
Builder: set link speed.
Sourcepub fn has_address(&self) -> bool
pub fn has_address(&self) -> bool
Whether this interface has any usable address.
Sourcepub fn primary_address(&self) -> Option<&IpAddr>
pub fn primary_address(&self) -> Option<&IpAddr>
Get the primary (first) address.
Sourcepub fn effective_priority(&self) -> u16
pub fn effective_priority(&self) -> u16
Effective routing priority (lower = preferred).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Interface
impl<'de> Deserialize<'de> for Interface
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Interface
impl RefUnwindSafe for Interface
impl Send for Interface
impl Sync for Interface
impl Unpin for Interface
impl UnsafeUnpin for Interface
impl UnwindSafe for Interface
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more