Expand description
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};
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?;§Error Handling
All operations return Result<T, ConnectionError>. The error type provides
specific variants for common failures like authentication errors, timeouts,
and missing devices.
Re-exports§
pub use models::ConnectionError;pub use models::ConnectionOptions;pub use models::Device;pub use models::DeviceState;pub use models::DeviceType;pub use models::EapMethod;pub use models::EapOptions;pub use models::Network;pub use models::NetworkInfo;pub use models::Phase2;pub use models::StateReason;pub use models::WifiSecurity;pub use models::reason_to_error;pub use network_manager::NetworkManager;
Modules§
- models
- network_
manager - wifi_
builders - NetworkManager connection settings builder.
Macros§
- try_log
- Macro to convert Result to Option with error logging.
Usage:
try_log!(result, "context message")?
Type Aliases§
- Result
- A specialized
Resulttype for network operations.