peach-workspace/peach-network/README.md

47 lines
1.5 KiB
Markdown
Raw Permalink Normal View History

2021-08-06 17:58:40 +00:00
# peach-network
2022-01-12 11:39:38 +00:00
![Generic badge](https://img.shields.io/badge/version-0.4.2-<COLOR>.svg)
2021-08-06 17:58:40 +00:00
Network interface state query and modification library.
2021-08-06 17:58:40 +00:00
Interaction with wireless interfaces occurs primarily through the [wpactrl crate](https://docs.rs/wpactrl/0.3.1/wpactrl/) which provides "a pure-Rust lowlevel library for controlling wpasupplicant remotely". This approach is akin to using `wpa_cli` (a WPA command line client).
## API Documentation
2021-08-06 17:58:40 +00:00
API documentation can be built and served with `cargo doc --no-deps --open`. The full set of available data structures and functions is listed in the `peach_network::network` module. A custom error type (`NetworkError`) is also publically exposed for library users; it encapsulates all possible error variants.
2021-08-06 17:58:40 +00:00
## Example Usage
2021-08-06 17:58:40 +00:00
```rust
use peach_network::{network, NetworkError};
2021-08-06 17:58:40 +00:00
fn main() -> Result<(), NetworkError> {
2022-01-03 09:55:20 +00:00
let wlan_iface = "wlan0";
2021-08-06 17:58:40 +00:00
2022-01-03 09:55:20 +00:00
let wlan_ip = network::ip(wlan_iface)?;
let wlan_ssid = network::ssid(wlan_iface)?;
let ssid = "Home";
let pass = "SuperSecret";
network::add(&wlan_iface, &ssid, &pass)?;
network::save()?;
2021-08-06 17:58:40 +00:00
Ok(())
}
```
2021-08-06 17:58:40 +00:00
2021-12-13 09:00:16 +00:00
## Feature Flags
2021-08-06 17:58:40 +00:00
2021-12-13 09:00:16 +00:00
Feature flags are used to offer `Serialize` and `Deserialize` implementations for all `struct` data types provided by this library. These traits are not provided by default. A choice of `miniserde` and `serde` is provided.
Define the desired feature in the `Cargo.toml` manifest of your project:
```toml
peach-network = { version = "0.3.0", features = ["miniserde_support"] }
```
## License
LGPL-3.0.