Rust Library for NetworkManager over D-Bus
⚓ Rust 📅 2026-07-16 👤 surdeus 👁️ 1nmrs makes it easier to write GUIs, network applications, system utilities and other programs in Rust, without writing heavy boilerplate zbus/dbus code.
To best demonstrate its use, compare the following implementations of scanning and listing available Wi-Fi networks and displaying them in nmrs, and non-blocking D-Bus, respectively.
use nmrs::{NetworkManager, WifiSecurity};
#[tokio::main]
async fn main() -> nmrs::Result<()> {
let nm = NetworkManager::new().await?;
// List networks
let networks = nm.list_networks().await?;
for net in &networks {
println!("{} - Signal: {}%", net.ssid, net.strength.unwrap_or(0));
}
// Connect to WPA-PSK network
nm.connect("MyNetwork", WifiSecurity::WpaPsk {
psk: "password".into()
}).await?;
// Check current connection
if let Some(ssid) = nm.current_ssid().await {
println!("Connected to: {}", ssid);
}
Ok(())
}
D-Bus version:
It supports Wi-Fi scanning and connections (including open, WPA/WPA2 Personal, and WPA Enterprise networks), Ethernet management, WireGuard and OpenVPN VPNs, importing OpenVPN profiles, creating and managing saved NetworkManager connection profiles, device and network state monitoring, radio controls (such as Wi-Fi and WWAN), internet connectivity and captive portal detection, real-time D-Bus event notifications, NetworkManager Secret Agent integration for handling credentials, and a fully asynchronous, strongly typed Rust API for interacting with NetworkManager without invoking a sub-process for nmcli or the likes.
It is now most notably featured on Pop!_OS' cosmic-settings and cosmic-applets.
Hope this is useful to someone. Thanks!
1 post - 1 participant
🏷️ Rust_feed