A NetworkManager API library using the D-Bus message bus system
This project is still under development. Currently implemented parts can be found in the docs.
Add networkmanager to your Cargo.toml
with:
toml
[dependencies]
networkmanager = "0.2"
```rust,no_run use networkmanager::devices::{Any, Wired, Wireless}; use networkmanager::types::DeviceType; use networkmanager::{Error, NetworkManager};
fn main() -> Result<(), Error> { let nm = NetworkManager::new()?;
let enp0s2 = nm.get_device_by_ip_iface("enp0s2")?;
for dev in nm.get_devices()? {
println!("Is autoconnected: {:?}", Any::autoconnect(&dev)?);
println!("Device Type: {:?}", Any::device_type(&dev)?);
match Any::device_type(&dev)? {
DeviceType::WiFi => {
println!("Access Point: {:?}", Wireless::access_points(&dev)?);
}
DeviceType::Ethernet => {
println!("Speed: {:?}", dev.speed()?);
println!(
"Permanent Hardware Address: {:?}",
Wired::perm_hw_address(&dev)?
);
println!("S390 Subchannels: {:?}", Wired::s390_subchannels(&dev)?);
println!("Carrier: {:?}", Wired::carrier(&dev)?);
}
_ => {}
}
}
Ok(())
} ```
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.