#[cfg(windows)]
pub mod native;
#[cfg(windows)]
pub mod adapters;
use std::fmt;
use serde::Serialize;
#[derive(Debug, Clone, Serialize)]
pub struct Interface {
pub guid: String,
pub name: String,
pub description: String,
pub state: InterfaceState,
pub connection: Option<ConnectionInfo>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
#[serde(rename_all = "snake_case")]
pub enum InterfaceState {
NotReady,
Connected,
AdHocNetworkFormed,
Disconnecting,
Disconnected,
Associating,
Discovering,
Authenticating,
Unknown,
}
impl fmt::Display for InterfaceState {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let s = match self {
InterfaceState::NotReady => "not ready",
InterfaceState::Connected => "connected",
InterfaceState::AdHocNetworkFormed => "ad-hoc formed",
InterfaceState::Disconnecting => "disconnecting",
InterfaceState::Disconnected => "disconnected",
InterfaceState::Associating => "associating",
InterfaceState::Discovering => "discovering",
InterfaceState::Authenticating => "authenticating",
InterfaceState::Unknown => "unknown",
};
f.write_str(s)
}
}
#[derive(Debug, Clone, Serialize)]
pub struct ConnectionInfo {
pub ssid: String,
pub bssid: String,
pub network_type: String,
pub radio_type: String,
pub authentication: String,
pub cipher: String,
pub connection_mode: String,
pub channel: Option<u32>,
pub band_ghz: Option<f32>,
pub rx_rate_mbps: Option<u32>,
pub tx_rate_mbps: Option<u32>,
pub signal_quality: Option<u8>,
pub profile_name: Option<String>,
}
#[derive(Debug, Clone, Serialize)]
pub struct NetworkInfo {
pub ssid: String,
pub network_type: String,
pub authentication: String,
pub encryption: String,
pub signal_quality: u8,
pub connectable: bool,
pub already_connected: bool,
pub profile_name: Option<String>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[allow(dead_code)]
pub enum ConnectOutcome {
Connected,
TimedOut,
Failed,
}