Feat(OSX): Add OSX Support

This commit is contained in:
Tochukwu Nkemdilim
2018-07-10 13:53:29 +01:00
parent 0089a0b5ed
commit 23355114c4
8 changed files with 75 additions and 40 deletions
+11 -7
View File
@@ -1,15 +1,20 @@
mod handlers;
pub mod profile_network;
mod providers;
#[cfg(target_os = "windows")]
mod handlers;
#[cfg(target_os = "windows")]
mod stubs;
use std::{fmt, io};
pub trait Network: fmt::Debug {
/// Makes an attempt to connect to a selected wireless network with password specified.
fn connect(&self, password: &str) -> Result<bool, NetworkError>;
fn disconnect(&self) -> Result<bool, NetworkError>;
fn connect(&self, password: &str) -> Result<bool, WifiConnectionError>;
fn disconnect(&self) -> Result<bool, WifiConnectionError>;
fn is_wifi_enabled(&self) -> bool;
fn connnection_up(&self) -> bool;
fn connnection_down(&self) -> bool;
}
// #[derive(Debug)]
@@ -25,8 +30,7 @@ pub struct Config<'a> {
}
#[derive(Debug)]
pub enum NetworkError {
// FromUtf8Error(FromUtf8Error),
pub enum WifiConnectionError {
SsidNotFound,
OsNotSupported,
IpAssignFailed,
@@ -37,8 +41,8 @@ pub enum NetworkError {
WiFiInterfaceDisabled,
}
impl From<io::Error> for NetworkError {
impl From<io::Error> for WifiConnectionError {
fn from(error: io::Error) -> Self {
NetworkError::IoError(error)
WifiConnectionError::IoError(error)
}
}