Feat(Linux): Integrate Linux Connectivity Feature

This commit is contained in:
Tochukwu Nkemdilim
2018-07-02 18:35:43 +01:00
parent bfd9385844
commit c46bf7f494
6 changed files with 112 additions and 152 deletions
+14 -6
View File
@@ -7,14 +7,20 @@ 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) -> bool;
fn connect(&self, password: &str) -> Result<bool, NetworkError>;
fn disconnect(&self) -> Result<bool, NetworkError>;
}
#[derive(Debug)]
pub enum NetworkType {
WEP,
WPA,
WPA2,
// #[derive(Debug)]
// pub enum NetworkType {
// WEP,
// WPA,
// WPA2,
// }
#[derive(Debug, Clone)]
pub struct Config<'a> {
pub interface: Option<&'a str>,
}
#[derive(Debug)]
@@ -23,8 +29,10 @@ pub enum NetworkError {
SsidNotFound,
OsNotSupported,
IpAssignFailed,
AddNetworkProfileFailed,
IoError(io::Error),
FailedToConnect(String),
FailedToDisconnect(String),
}
impl From<io::Error> for NetworkError {