Merge pull request #6 from TNkemdilim/hotfix/minor-cleanup
Chore(Cleanup): Resolve Warnings
This commit is contained in:
+5
-2
@@ -2,16 +2,19 @@ mod providers;
|
|||||||
|
|
||||||
use self::providers::prelude::HotspotConfig;
|
use self::providers::prelude::HotspotConfig;
|
||||||
use crate::platforms::{WifiError, WifiInterface};
|
use crate::platforms::{WifiError, WifiInterface};
|
||||||
use std::{fmt, io};
|
use std::fmt;
|
||||||
|
|
||||||
/// Error that might occur when interacting managing wireless hotspot.
|
/// Error that might occur when interacting managing wireless hotspot.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum WifiHotspotError {
|
pub enum WifiHotspotError {
|
||||||
/// Failed to ceate wireless hotspot.
|
/// Failed to ceate wireless hotspot.
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
CreationFailed,
|
CreationFailed,
|
||||||
/// Failed to stop wireless hotspot service. Try turning off
|
/// Failed to stop wireless hotspot service. Try turning off
|
||||||
/// the wireless interface via ```wifi.turn_off()```.
|
/// the wireless interface via ```wifi.turn_off()```.
|
||||||
FailedToStop(io::Error),
|
#[cfg(target_os = "linux")]
|
||||||
|
FailedToStop(std::io::Error),
|
||||||
/// A wireless interface error occurred.
|
/// A wireless interface error occurred.
|
||||||
Other { kind: WifiError },
|
Other { kind: WifiError },
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ pub enum HotspotBand {
|
|||||||
Bg,
|
Bg,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
/// Channel to broadcast wireless hotspot on.
|
/// Channel to broadcast wireless hotspot on.
|
||||||
pub enum Channel {
|
pub enum Channel {
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
use hotspot::{WifiHotspot, WifiHotspotError};
|
use hotspot::WifiHotspot;
|
||||||
use connectivity::{Connectivity, WifiConnectionError};
|
|
||||||
use platforms::WiFi;
|
use platforms::WiFi;
|
||||||
use std::process::Command;
|
|
||||||
|
|
||||||
/// Configuration for a wireless hotspot.
|
/// Configuration for a wireless hotspot.
|
||||||
|
#[allow(dead_code)]
|
||||||
pub struct HotspotConfig {}
|
pub struct HotspotConfig {}
|
||||||
|
|
||||||
/// Wireless hotspot functionality for a wifi interface.
|
/// Wireless hotspot functionality for a wifi interface.
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ impl WifiInterface for Linux {
|
|||||||
|
|
||||||
/// Turn on the wireless network adapter.
|
/// Turn on the wireless network adapter.
|
||||||
fn turn_on() -> Result<(), WifiError> {
|
fn turn_on() -> Result<(), WifiError> {
|
||||||
let _output = Command::new("nmcli")
|
Command::new("nmcli")
|
||||||
.args(&["radio", "wifi", "on"])
|
.args(&["radio", "wifi", "on"])
|
||||||
.output()
|
.output()
|
||||||
.map_err(|err| WifiError::IoError(err))?;
|
.map_err(|err| WifiError::IoError(err))?;
|
||||||
@@ -52,7 +52,7 @@ impl WifiInterface for Linux {
|
|||||||
|
|
||||||
/// Turn off the wireless network adapter.
|
/// Turn off the wireless network adapter.
|
||||||
fn turn_off() -> Result<(), WifiError> {
|
fn turn_off() -> Result<(), WifiError> {
|
||||||
let _output = Command::new("nmcli")
|
Command::new("nmcli")
|
||||||
.args(&["radio", "wifi", "off"])
|
.args(&["radio", "wifi", "off"])
|
||||||
.output()
|
.output()
|
||||||
.map_err(|err| WifiError::IoError(err))?;
|
.map_err(|err| WifiError::IoError(err))?;
|
||||||
|
|||||||
@@ -33,15 +33,12 @@ impl WifiInterface for Osx {
|
|||||||
.output()
|
.output()
|
||||||
.map_err(|err| WifiError::IoError(err))?;
|
.map_err(|err| WifiError::IoError(err))?;
|
||||||
|
|
||||||
Ok(String::from_utf8_lossy(&output.stdout)
|
Ok(String::from_utf8_lossy(&output.stdout).contains("enabled"))
|
||||||
.replace(" ", "")
|
|
||||||
.replace("\n", "")
|
|
||||||
.contains("enabled"))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Turn on the wireless network adapter.
|
/// Turn on the wireless network adapter.
|
||||||
fn turn_on() -> Result<(), WifiError> {
|
fn turn_on() -> Result<(), WifiError> {
|
||||||
let output = Command::new("networksetup")
|
Command::new("networksetup")
|
||||||
.args(&["-setairportpower", "en0", "on"])
|
.args(&["-setairportpower", "en0", "on"])
|
||||||
.output()
|
.output()
|
||||||
.map_err(|err| WifiError::IoError(err))?;
|
.map_err(|err| WifiError::IoError(err))?;
|
||||||
@@ -51,7 +48,7 @@ impl WifiInterface for Osx {
|
|||||||
|
|
||||||
/// Turn off the wireless adapter.
|
/// Turn off the wireless adapter.
|
||||||
fn turn_off() -> Result<(), WifiError> {
|
fn turn_off() -> Result<(), WifiError> {
|
||||||
let output = Command::new("networksetup")
|
Command::new("networksetup")
|
||||||
.args(&["-setairportpower", "en0", "off"])
|
.args(&["-setairportpower", "en0", "off"])
|
||||||
.output()
|
.output()
|
||||||
.map_err(|err| WifiError::IoError(err))?;
|
.map_err(|err| WifiError::IoError(err))?;
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ impl WifiInterface for Windows {
|
|||||||
|
|
||||||
/// Turn on the wireless network adapter.
|
/// Turn on the wireless network adapter.
|
||||||
fn turn_on() -> Result<(), WifiError> {
|
fn turn_on() -> Result<(), WifiError> {
|
||||||
let _output = Command::new("netsh")
|
Command::new("netsh")
|
||||||
.args(&[
|
.args(&[
|
||||||
"interface",
|
"interface",
|
||||||
"set",
|
"set",
|
||||||
|
|||||||
Reference in New Issue
Block a user