Crates.io | uci_rs |
lib.rs | uci_rs |
version | 0.1.2 |
source | src |
created_at | 2023-04-15 16:45:22.780738 |
updated_at | 2023-04-18 19:08:55.729372 |
description | an openwrt's UCI (Unified Configuration Interface) parser and serializer. |
homepage | |
repository | |
max_upload_size | |
id | 840040 |
size | 135,456 |
An openwrt's UCI (Unified Configuration Interface) parser and serializer.
Add this to your Cargo.toml
:
[dependencies]
uci_rs = "0.1.0"
Example:
use uci_rs::{load_config, Uci, UciCommand};
/// file_path: /etc/config/network
///
/// config interface 'lan'
/// option type 'bridge'
/// option ifname 'eth0.1'
/// option proto 'static'
/// option netmask '255.255.255.0'
/// option ip6assign '60'
/// option ipaddr '192.168.1.1'
///
/// config interface 'wan'
/// option ifname 'eth0.2'
/// option proto 'dhcp'
fn main(){
let uci_network = load_config("network", "/etc/config")?;
assert_eq!(uci.get_package(), "network");
assert_eq!(uci.get_section("wan"), Ok(("interface", "wan" )));
assert_eq!(uci.get_option("wan", "ifname"), Ok(("ifname", ["eth0.2"])));
assert_eq!(uci.get_option("lan", "proto"), Ok(("proto", ["static"])));
}
uci_rs is distributed under the LICENSE-MIT .