#[non_exhaustive]pub struct Network {Show 16 fields
pub device: String,
pub ssid: String,
pub bssid: Option<String>,
pub strength: Option<u8>,
pub frequency: Option<u32>,
pub secured: bool,
pub is_psk: bool,
pub is_eap: bool,
pub is_hotspot: bool,
pub ip4_address: Option<String>,
pub ip6_address: Option<String>,
pub best_bssid: String,
pub bssids: Vec<String>,
pub is_active: bool,
pub known: bool,
pub security_features: SecurityFeatures,
}Expand description
Represents a Wi-Fi network discovered during a scan.
This struct contains information about a WiFi network that was discovered by NetworkManager during a scan operation.
§Examples
use nmrs::NetworkManager;
let nm = NetworkManager::new().await?;
// Scan for networks (None = all Wi-Fi devices)
nm.scan_networks(None).await?;
let networks = nm.list_networks(None).await?;
for net in networks {
println!("SSID: {}", net.ssid);
println!(" Signal: {}%", net.strength.unwrap_or(0));
println!(" Secured: {}", net.secured);
if let Some(freq) = net.frequency {
let band = if freq > 5000 { "5GHz" } else { "2.4GHz" };
println!(" Band: {}", band);
}
}Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.device: StringDevice interface name (e.g., “wlan0”)
ssid: StringNetwork SSID (name)
bssid: Option<String>Access point MAC address (BSSID)
strength: Option<u8>Signal strength (0-100)
frequency: Option<u32>Frequency in MHz (e.g., 2437 for channel 6)
secured: boolWhether the network requires authentication
is_psk: boolWhether the network uses WPA-PSK authentication
is_eap: boolWhether the network uses WPA-EAP (Enterprise) authentication
is_hotspot: boolWhether the access point is operating in AP (hotspot) mode
ip4_address: Option<String>Assigned IPv4 address with CIDR notation (only present when connected)
ip6_address: Option<String>Assigned IPv6 address with CIDR notation (only present when connected)
best_bssid: StringBSSID of the strongest AP for this SSID.
bssids: Vec<String>All known BSSIDs for this SSID, strongest first.
is_active: booltrue if this network is currently active (connected).
known: booltrue if a saved connection profile exists for this SSID.
security_features: SecurityFeaturesDecoded security capabilities from NM flag triplet.
Implementations§
Source§impl Network
impl Network
Sourcepub fn merge_ap(&mut self, other: &Network)
pub fn merge_ap(&mut self, other: &Network)
Merges another access point’s information into this network.
When multiple access points share the same SSID (e.g., mesh networks), this method keeps the strongest signal and combines security flags. Used internally during network scanning to deduplicate results.