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");
}
if let Some(driver) = &device.driver {
println!(" Driver: {}", driver);
}
}Fields§
§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§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)