Refactor(Project): Change Project Structure

This commit is contained in:
Tochukwu Nkemdilim
2018-07-19 16:14:34 +01:00
parent e8b83bf245
commit 65c641670d
17 changed files with 268 additions and 250 deletions
+9 -4
View File
@@ -1,6 +1,5 @@
mod providers;
// pub use self::providers::Machine;
use platforms::{WifiError, WifiInterface};
use std::fmt;
@@ -15,13 +14,19 @@ pub trait WifiHotspot: fmt::Debug + WifiInterface {
/// Creates wifi hotspot service for host machine. This only creats the wifi network,
/// and isn't responsible for initiating the serving of the wifi network process.
/// To begin serving the hotspot, use ```start_hotspot()```.
fn create_hotspot(ssid: &str, password: &str) -> Result<bool, WifiHotspotError>;
fn create_hotspot(ssid: &str, password: &str) -> Result<bool, WifiHotspotError> {
unimplemented!();
}
/// Start serving publicly an already created wifi hotspot.
fn start_hotspot() -> Result<bool, WifiHotspotError>;
fn start_hotspot() -> Result<bool, WifiHotspotError> {
unimplemented!();
}
/// Stop serving a wifi network.
///
/// > All users connected will automatically be disconnected.
fn stop_hotspot() -> Result<bool, WifiHotspotError>;
fn stop_hotspot() -> Result<bool, WifiHotspotError> {
unimplemented!();
}
}
+3 -30
View File
@@ -1,31 +1,4 @@
use hotspot::{WifiHotspot, WifiHotspotError};
use platforms::Linux;
use hotspot::WifiHotspot;
use platforms::WiFi;
// #[derive(Debug)]
// pub struct Linux {
// pub name: String,
// interface: String,
// }
// impl Linux {
// pub fn new(name: &str, interface: Option<&str>) -> Self {
// Linux {
// name: name.into(),
// interface: interface.unwrap_or("wlan0").into(),
// }
// }
// }
impl WifiHotspot for Linux {
fn create_hotspot(ssid: &str, password: &str) -> Result<bool, WifiHotspotError> {
unimplemented!();
}
fn start_hotspot() -> Result<bool, WifiHotspotError> {
unimplemented!();
}
fn stop_hotspot() -> Result<bool, WifiHotspotError> {
unimplemented!();
}
}
impl WifiHotspot for WiFi {}
+6 -12
View File
@@ -1,14 +1,8 @@
// #[cfg(target_os = "windows")]
// mod windows;
// #[cfg(target_os = "windows")]
// pub use self::windows::Windows as Machine;
#[cfg(target_os = "windows")]
mod windows;
// #[cfg(target_os = "linux")]
// mod linux;
// #[cfg(target_os = "linux")]
// pub use self::linux as Machine;
#[cfg(target_os = "linux")]
mod linux;
// #[cfg(target_os = "osx")]
// mod osx;
// #[cfg(target_os = "osx")]
// pub use self::osx::OSX as Machine;
#[cfg(target_os = "osx")]
mod osx;
+2 -15
View File
@@ -1,18 +1,5 @@
use connectivity::{Network, WifiConnectionError};
use platforms::WiFi;
use std::process::Command;
#[derive(Debug)]
pub struct OSX {
pub name: String,
interface: String,
}
impl OSX {
#[cfg(target_os = "windows")]
pub fn new(name: &str, interface: Option<&str>) -> Self {
OSX {
name: name.into(),
interface: interface.unwrap_or("en0").into(),
}
}
}
impl WifiHotspot for WiFi {}
+2 -7
View File
@@ -2,15 +2,10 @@ use connectivity::handlers::NetworkXmlProfileHandler;
use connectivity::{
Network, WifiConnectionError, WifiError, WifiHotspot, WifiHotspotError, WifiInterface,
};
use platforms::Windows;
use platforms::WiFi;
use std::process::Command;
// #[derive(Debug)]
// pub(crate) struct Windows {
// name: String,
// }
impl WifiHotspot for Windows {
impl WifiHotspot for WiFi {
fn create_hotspot(ssid: &str, password: &str) -> Result<bool, WifiHotspotError> {
let output = Command::new("netsh")
.args(&[