peach-workspace/peach-network/README.md

1.5 KiB

peach-network

Generic badge

Network interface state query and modification library.

Interaction with wireless interfaces occurs primarily through the wpactrl crate 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

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.

Example Usage

use peach_network::{network, NetworkError};

fn main() -> Result<(), NetworkError> {
    let wlan_iface = "wlan0";

    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()?;

    Ok(())
}

Feature Flags

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:

peach-network = { version = "0.3.0", features = ["miniserde_support"] }

License

LGPL-3.0.