#[non_exhaustive]pub struct Device {
pub path: String,
pub interface: String,
pub identity: DeviceIdentity,
pub device_type: DeviceType,
pub state: DeviceState,
pub managed: Option<bool>,
pub driver: Option<String>,
}Expand description
Represents a network device managed by NetworkManager.
A device can be a WiFi adapter, Ethernet interface, or other network hardware.
§Examples
use nmrs::NetworkManager;
let nm = NetworkManager::new().await?;
let devices = nm.list_devices().await?;
for device in devices {
println!("Interface: {}", device.interface);
println!(" Type: {}", device.device_type);
println!(" State: {}", device.state);
println!(" MAC: {}", device.identity.current_mac);
if device.is_wireless() {
println!(" This is a WiFi device");
} else if device.is_wired() {
println!(" This is an Ethernet device");
} else if device.is_bluetooth() {
println!(" This is a Bluetooth device");
}
if let Some(driver) = &device.driver {
println!(" Driver: {}", driver);
}
}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.path: StringD-Bus object path
interface: StringInterface name (e.g., “wlan0”, “eth0”)
identity: DeviceIdentityDevice hardware identity (MAC addresses)
device_type: DeviceTypeType of device (WiFi, Ethernet, etc.)
state: DeviceStateCurrent device state
managed: Option<bool>Whether NetworkManager manages this device
driver: Option<String>Kernel driver name
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Device
impl RefUnwindSafe for Device
impl Send for Device
impl Sync for Device
impl Unpin for Device
impl UnwindSafe for Device
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