1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
//! `kawaiifi` is a Wi-Fi scanning library for Linux, macOS, and Windows.
//!
//! It discovers local Basic Service Sets (BSSs) and reports their SSID, BSSID,
//! signal strength, channel, channel width, security protocols, and information
//! elements (IEs).
//!
//! ## Obtaining a Wi-Fi Interface
//!
//! Use [`default_interface`] to get the first available interface.
//!
//! ```
//! # fn example() -> Result<(), Box<dyn std::error::Error>> {
//! use kawaiifi::Interface;
//!
//! let interface: Interface = kawaiifi::default_interface()?.ok_or("No Wi-Fi interface found")?;
//! # Ok(())
//! # }
//! ```
//!
//! Use [`interfaces`] to get all available interfaces.
//!
//! ```
//! # fn example() -> Result<(), Box<dyn std::error::Error>> {
//! use kawaiifi::Interface;
//!
//! let interfaces: Vec<Interface> = kawaiifi::interfaces()?;
//! # Ok(())
//! # }
//! ```
//!
//! Some [`Interface`] properties are platform-specific.
//!
//! ```
//! # fn print_interface_properties(interface: &kawaiifi::Interface) {
//! #[cfg(target_os = "linux")]
//! println!("Index: {}", interface.index());
//!
//! #[cfg(target_os = "macos")]
//! println!("Noise: {} dBm", interface.noise_dbm());
//!
//! #[cfg(target_os = "windows")]
//! println!("Description: {}", interface.description());
//! # }
//! ```
//!
//! ## Triggering a Wi-Fi Scan
//!
//! Blocking scans are triggered using [`Interface::scan_blocking`].
//!
//! ```no_run
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! use kawaiifi::Scan;
//!
//! # let interface = kawaiifi::default_interface()?.ok_or("No Wi-Fi interface found")?;
//! let scan: Scan = interface.scan_blocking()?;
//! # Ok(())
//! # }
//! ```
//! Asynchronous scans are triggered using [`Interface::scan`].
//!
//! ```no_run
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! # let interface = kawaiifi::default_interface()?
//! # .expect("Expected to find a wireless interface");
//! let scan = interface.scan().await?;
//! # Ok(())
//! # }
//! ```
//!
//! ## Accessing BSS Data
//!
//! [`Scan`] contains a list of BSSs that are accessed through
//! [`Scan::bss_list`].
//!
//! ```
//! # fn print_bss_count(scan: &kawaiifi::Scan) {
//! use kawaiifi::Bss;
//!
//! let bss_list: &[Bss] = scan.bss_list();
//! println!("Found {} BSS(s)", bss_list.len());
//! # }
//! ```
//!
//! [`Bss`] exposes common properties that are available on all platforms.
//!
//! ```
//! # fn print_bss_data(bss: &kawaiifi::Bss) {
//! println!("BSSID: {:?}", bss.bssid());
//! println!("SSID: {:?}", bss.ssid());
//! println!("Frequency: {} MHz", bss.frequency_mhz());
//! println!("Band: {}", bss.band());
//! println!("Channel: {}", bss.channel_number());
//! println!("Channel Width: {}", bss.channel_width());
//! println!("Signal: {} dBm", bss.signal_dbm());
//! println!("Security: {}", bss.security_protocols());
//! println!("Wi-Fi Protocols: {}", bss.wifi_protocols());
//! println!("Wi-Fi Amendments: {}", bss.wifi_amendments());
//! println!("Max Rate: {} Mbps", bss.max_rate_mbps());
//! # }
//! ```
//!
//! Some [`Bss`] properties are platform-specific.
//!
//! ```
//! # fn print_platform_bss_data(bss: &kawaiifi::Bss) {
//! #[cfg(target_os = "linux")]
//! println!("Status: {:?}", bss.status());
//!
//! #[cfg(target_os = "macos")]
//! println!("Noise: {} dBm", bss.noise_dbm());
//!
//! #[cfg(target_os = "windows")]
//! println!("Link Quality: {}", bss.link_quality());
//! # }
//! ```
//!
//! ## Accessing Information Elements
//!
//! [`Bss`] contains a list of 802.11 Information Elements (IEs) that are
//! accessed through [`Bss::ies`].
//!
//! ```
//! # fn print_ie_count(bss: &kawaiifi::Bss) {
//! use kawaiifi::Ie;
//!
//! let ies: &[Ie] = bss.ies();
//! println!("Found {} IE(s)", ies.len());
//! # }
//! ```
//!
//! [`Ie`] exposes basic properties such as the information element's name, ID,
//! and a summary.
//!
//! ```
//! # fn print_ie(ie: &kawaiifi::Ie) {
//! println!("IE: {} ({}) - {}", ie.name(), ie.id, ie.summary());
//! # }
//! ```
//!
//! [`Ie`] also exposes the information element's underlying data through
//! [`Ie::data`].
//!
//! ```
//! use kawaiifi::IeData;
//!
//! # fn print_ie_data(ie: &kawaiifi::Ie) {
//! match &ie.data {
//! IeData::Ssid(ssid) => println!("SSID: {}", ssid.to_string_lossy()),
//! IeData::DsParameterSet(ds) => println!("Channel: {}", ds.current_channel),
//! IeData::Tim(tim) => println!("DTIM Period: {}", tim.dtim_period),
//! IeData::VhtCapabilities(vht_caps) => {
//! println!("Max MPDU Length: {}", vht_caps.vht_capabilities_info.maximum_mpdu_length)
//! }
//! _ => {}
//! }
//! # }
//! ```
pub use Band;
pub use Bss;
pub use CapabilityInfo;
pub use ;
pub use ;
pub use BusType;
pub use ;
pub use BssStatus;
pub use Error as ScanError;
pub use Flags as ScanFlags;
pub use Scan;
pub use ;
pub use ;
pub use ;