Expand description
Network management via NetworkManager D-Bus.
§Quick Start
use wayle_network::NetworkService;
let net = NetworkService::new().await?;
// Check WiFi state (wifi is reactive for hot-plug support)
if let Some(wifi) = net.wifi.get() {
println!("WiFi enabled: {}", wifi.enabled.get());
for ap in wifi.access_points.get().iter() {
println!(" {} ({}%)", ap.ssid.get(), ap.strength.get());
}
}
// Check wired state
if let Some(wired) = net.wired.get() {
println!("Ethernet status: {:?}", wired.connectivity.get());
}§Watching for Changes
use wayle_network::NetworkService;
use futures::StreamExt;
if let Some(wifi) = net.wifi.get() {
let mut stream = wifi.access_points.watch();
while let Some(aps) = stream.next().await {
println!("{} networks visible", aps.len());
}
}§WiFi Control
if let Some(wifi) = net.wifi.get() {
// Enable WiFi
wifi.set_enabled(true).await?;
// List available networks
for ap in wifi.access_points.get().iter() {
println!("{}: {:?} ({}%)",
ap.ssid.get(),
ap.security.get(),
ap.strength.get()
);
}
}§Reactive Properties
All fields are Property<T>:
.get()- Current value snapshot.watch()- Stream yielding on changes
§Service Fields
| Field | Type | Description |
|---|---|---|
wifi | Property<Option<Arc<Wifi>>> | WiFi device (reactive for hot-plug) |
wired | Property<Option<Arc<Wired>>> | Ethernet device (reactive for hot-plug) |
settings | Settings | Connection profile management |
primary | Property<ConnectionType> | Active connection type |
Modules§
- core
- Core network domain models.
- types
- Network type definitions
- wifi
- WiFi device functionality
- wired
- Wired device functionality
Structs§
- Network
Service - Entry point for network management. See crate-level docs for usage.
Enums§
- Error
- Network service errors