cadmus_core/device/wifi/manager.rs
1//! WiFi Manager trait definition.
2
3use crate::device::wifi::error::WifiError;
4
5/// Trait for WiFi management.
6///
7/// This trait abstracts over platform-specific implementations that enable
8/// and disable WiFi connectivity.
9///
10/// # Lifecycle
11///
12/// 1. Call [`enable`](WifiManager::enable) when the user wants to connect
13/// to a WiFi network.
14/// 2. Call [`disable`](WifiManager::disable) when the user disconnects.
15///
16/// # Example
17///
18/// ```ignore
19/// use cadmus_core::device::wifi::{WifiManager, WifiError};
20///
21/// # fn example(wifi_manager: &dyn WifiManager) -> Result<(), WifiError> {
22/// // Enable WiFi
23/// wifi_manager.enable()?;
24///
25/// // ... device is now connected to WiFi ...
26///
27/// // Disable WiFi
28/// wifi_manager.disable()?;
29/// # Ok(())
30/// # }
31/// ```
32pub trait WifiManager: Send + Sync {
33 /// Enables WiFi connectivity.
34 ///
35 /// # Errors
36 ///
37 /// Returns [`WifiError`] if enabling fails.
38 ///
39 /// # Example
40 ///
41 /// ```ignore
42 /// use cadmus_core::device::wifi::WifiManager;
43 ///
44 /// # fn example(wifi_manager: &dyn WifiManager) -> Result<(), cadmus_core::device::wifi::WifiError> {
45 /// wifi_manager.enable()?;
46 /// # Ok(())
47 /// # }
48 /// ```
49 fn enable(&self) -> Result<(), WifiError>;
50
51 /// Disables WiFi connectivity.
52 ///
53 /// # Errors
54 ///
55 /// Returns [`WifiError`] if disabling fails.
56 ///
57 /// # Example
58 ///
59 /// ```ignore
60 /// use cadmus_core::device::wifi::WifiManager;
61 ///
62 /// # fn example(wifi_manager: &dyn WifiManager) -> Result<(), cadmus_core::device::wifi::WifiError> {
63 /// wifi_manager.disable()?;
64 /// # Ok(())
65 /// # }
66 /// ```
67 fn disable(&self) -> Result<(), WifiError>;
68}