A Rust library for managing Wi-Fi connections via NetworkManager.
This crate provides a high-level async API for common Wi-Fi operations:
- Listing network devices and visible networks
- Connecting to open, WPA-PSK, and WPA-EAP networks
- Managing saved connection profiles
- Enabling/disabling Wi-Fi
Example
use nmrs::{NetworkManager, WifiSecurity};
# async fn example() -> nmrs::Result<()> {
let nm = NetworkManager::new().await?;
// List visible networks
let networks = nm.list_networks().await?;
for net in &networks {
println!("{} ({}%)", net.ssid, net.strength.unwrap_or(0));
}
// Connect to a network
nm.connect("MyNetwork", WifiSecurity::WpaPsk {
psk: "password123".into()
}).await?;
# Ok(())
# }
Error Handling
All operations return Result<T, ConnectionError>. The error type provides
specific variants for common failures like authentication errors, timeouts,
and missing devices.