Skip to main content

wayle_network/
lib.rs

1//! Network management via NetworkManager D-Bus.
2//!
3//! # Quick Start
4//!
5//! ```rust,no_run
6//! use wayle_network::NetworkService;
7//!
8//! # async fn example() -> Result<(), wayle_network::Error> {
9//! let net = NetworkService::new().await?;
10//!
11//! // Check WiFi state (wifi is reactive for hot-plug support)
12//! if let Some(wifi) = net.wifi.get() {
13//!     println!("WiFi enabled: {}", wifi.enabled.get());
14//!     for ap in wifi.access_points.get().iter() {
15//!         println!("  {} ({}%)", ap.ssid.get(), ap.strength.get());
16//!     }
17//! }
18//!
19//! // Check wired state
20//! if let Some(wired) = net.wired.get() {
21//!     println!("Ethernet status: {:?}", wired.connectivity.get());
22//! }
23//! # Ok(())
24//! # }
25//! ```
26//!
27//! # Watching for Changes
28//!
29//! ```rust,no_run
30//! use wayle_network::NetworkService;
31//! use futures::StreamExt;
32//!
33//! # async fn example() -> Result<(), wayle_network::Error> {
34//! # let net = NetworkService::new().await?;
35//! if let Some(wifi) = net.wifi.get() {
36//!     let mut stream = wifi.access_points.watch();
37//!     while let Some(aps) = stream.next().await {
38//!         println!("{} networks visible", aps.len());
39//!     }
40//! }
41//! # Ok(())
42//! # }
43//! ```
44//!
45//! # WiFi Control
46//!
47//! ```rust,no_run
48//! # use wayle_network::NetworkService;
49//! # async fn example() -> Result<(), wayle_network::Error> {
50//! # let net = NetworkService::new().await?;
51//! if let Some(wifi) = net.wifi.get() {
52//!     // Enable WiFi
53//!     wifi.set_enabled(true).await?;
54//!
55//!     // List available networks
56//!     for ap in wifi.access_points.get().iter() {
57//!         println!("{}: {:?} ({}%)",
58//!             ap.ssid.get(),
59//!             ap.security.get(),
60//!             ap.strength.get()
61//!         );
62//!     }
63//! }
64//! # Ok(())
65//! # }
66//! ```
67//!
68//! # Reactive Properties
69//!
70//! All fields are [`Property<T>`](wayle_core::Property):
71//! - `.get()` - Current value snapshot
72//! - `.watch()` - Stream yielding on changes
73//!
74//! # Service Fields
75//!
76//! | Field | Type | Description |
77//! |-------|------|-------------|
78//! | `wifi` | `Property<Option<Arc<Wifi>>>` | WiFi device (reactive for hot-plug) |
79//! | `wired` | `Property<Option<Arc<Wired>>>` | Ethernet device (reactive for hot-plug) |
80//! | `settings` | `Settings` | Connection profile management |
81//! | `primary` | `Property<ConnectionType>` | Active connection type |
82
83/// Core network domain models.
84pub mod core;
85mod discovery;
86mod error;
87mod monitoring;
88mod proxy;
89mod service;
90/// Network type definitions
91pub mod types;
92/// WiFi device functionality
93pub mod wifi;
94/// Wired device functionality
95pub mod wired;
96
97pub use error::Error;
98pub use service::NetworkService;