wifi_rs/hotspot/
mod.rs

1pub mod providers;
2
3use self::providers::prelude::HotspotConfig;
4use crate::platforms::{WifiError, WifiInterface};
5use std::fmt;
6
7/// Error that might occur when interacting managing wireless hotspot.
8#[derive(Debug)]
9pub enum WifiHotspotError {
10    /// Failed to ceate wireless hotspot.s
11    #[cfg(any(target_os = "windows", target_os = "linux"))]
12    CreationFailed,
13
14    /// Failed to stop wireless hotspot service. Try turning off
15    /// the wireless interface via ```wifi.turn_off()```.
16    #[cfg(target_os = "linux")]
17    FailedToStop(std::io::Error),
18
19    /// A wireless interface error occurred.
20    Other { kind: WifiError },
21}
22
23/// Wireless hotspot functionality for a wifi interface.
24pub trait WifiHotspot: fmt::Debug + WifiInterface {
25    /// Creates wireless hotspot service for host machine. This only creates the wifi network,
26    /// and isn't responsible for initiating the serving of the wifi network process.
27    /// To begin serving the hotspot, use ```start_hotspot()```.
28    fn create_hotspot(
29        &mut self,
30        ssid: &str,
31        password: &str,
32        configuration: Option<&HotspotConfig>,
33    ) -> Result<bool, WifiHotspotError> {
34        let _a = ssid;
35        let _b = password;
36        let _c = configuration;
37
38        unimplemented!();
39    }
40
41    /// Start serving publicly an already created wireless hotspot.
42    fn start_hotspot() -> Result<bool, WifiHotspotError> {
43        unimplemented!();
44    }
45
46    /// Stop serving a wireless network.
47    /// **NOTE: All users connected will automatically be disconnected.**
48    fn stop_hotspot(&mut self) -> Result<bool, WifiHotspotError> {
49        unimplemented!();
50    }
51}
52
53impl From<WifiError> for WifiHotspotError {
54    fn from(error: WifiError) -> Self {
55        WifiHotspotError::Other { kind: error }
56    }
57}