| Crates.io | networkmanager |
| lib.rs | networkmanager |
| version | 0.5.0 |
| created_at | 2020-06-06 21:02:08.341862+00 |
| updated_at | 2025-06-26 19:57:53.886163+00 |
| description | Bindings for the Linux NetworkManager |
| homepage | |
| repository | https://github.com/zibebe/networkmanager-rs |
| max_upload_size | |
| id | 250801 |
| size | 236,419 |
NetworkManager bindings for Rust using the D-Bus message bus system
NOTE: At the moment i dont have any time to take care of this project. Contributors welcome!!
This project is still under development. Currently implemented parts can be found in the docs.
Add networkmanager and dbus to your Cargo.toml with:
[dependencies]
networkmanager = "0.5"
dbus = "0.9"
use networkmanager::devices::{Any, Device, Wired, Wireless};
use networkmanager::{Error, NetworkManager};
use dbus::blocking::Connection;
fn main() -> Result<(), Error> {
let dbus_connection = Connection::new_system()?;
let nm = NetworkManager::new(&dbus_connection);
for dev in nm.get_devices()? {
match dev {
Device::Ethernet(x) => {
println!("Is autoconnected: {:?}", x.autoconnect()?);
println!("Speed: {:?}", x.speed()?);
println!("S390 Subchannels: {:?}", x.s390_subchannels()?);
println!("Carrier: {:?}", x.carrier()?);
}
Device::WiFi(x) => {
println!("Bitrate: {:?}", x.bitrate()?);
x.request_scan(std::collections::HashMap::new())?;
for ap in x.get_all_access_points()? {
println!("SSID: {:?}", ap.ssid()?);
}
}
_ => {}
}
}
let eth0 = nm.get_device_by_ip_iface("eth0")?;
match eth0 {
Device::Ethernet(x) => {
// NetworkManager >= 1.24
// println!("Hardware Address: {:?}", Any::hw_address(&x)?);
// NetworkManager < 1.24
// println!("Hardware Address: {:?}", Wired::hw_address(&x)?);
println!("Speed: {:?}", x.speed()?);
}
_ => {}
}
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.