wifi_rs/platforms/
mod.rs

1#[cfg(target_os = "linux")]
2mod linux;
3#[cfg(target_os = "macos")]
4mod osx;
5#[cfg(target_os = "windows")]
6mod windows;
7
8#[cfg(target_os = "linux")]
9pub use self::linux::{Connection, Linux as WiFi};
10#[cfg(target_os = "macos")]
11pub use self::osx::{Connection, Osx as WiFi};
12#[cfg(target_os = "windows")]
13pub use self::windows::{Connection, Windows as WiFi};
14
15use std::{fmt, io};
16
17/// Configuration for a wifi network.
18#[derive(Debug, Clone)]
19pub struct Config<'a> {
20    /// The interface the wifi module is situated.
21    pub interface: Option<&'a str>,
22}
23
24#[derive(Debug)]
25pub enum WifiError {
26    // The specified wifi  is currently disabled. Try switching it on.
27    WifiDisabled,
28    /// The wifi interface interface failed to switch on.
29    #[cfg(target_os = "windows")]
30    InterfaceFailedToOn,
31    /// IO Error occurred.
32    IoError(io::Error),
33}
34
35/// Wifi interface for an operating system.
36/// This provides basic functionalities for wifi interface.
37pub trait WifiInterface: fmt::Debug {
38    /// Check if the wifi interface on host machine is enabled.
39    fn is_wifi_enabled() -> Result<bool, WifiError> {
40        unimplemented!();
41    }
42
43    /// Turn on the wifi interface of host machine.
44    fn turn_on() -> Result<(), WifiError> {
45        unimplemented!();
46    }
47
48    /// Turn off the wifi interface of host machine.
49    fn turn_off() -> Result<(), WifiError> {
50        unimplemented!();
51    }
52}