1 unstable release
0.1.5 | May 22, 2021 |
---|---|
0.1.4 |
|
0.1.0 |
|
#779 in Configuration
56 downloads per month
380KB
13K
SLoC
rust-uci
OpenWRT libuci bindings for the Rust programming language.
License
libuci is licensed under GPLv2.
The files in this repository are licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
lib.rs
:
Bindings to OpenWRT UCI
This crate provides a safe interface to OpenWRT's Unified Configuration Interface C-Library.
Building
Both UCI libraries and headers are required to build this crate. There are multiple options available to locate UCI.
Inside OpenWRT SDK
If building inside the OpenWRT SDK with OpenWRT's UCI package set the environment variable
UCI_DIR=$(STAGING_DIR)/usr
using the corresponding Makefile.
rust-uci will automatically use the headers and libraries for the target system.
Vendored
If no UCI_DIR
variable is set, rust-uci will compile against the distributed libuci source files licensed under GPLv2.
Example Usage
use rust_uci::Uci;
let mut uci = Uci::new()?;
// Get type of a section
assert_eq!(uci.get("network.wan")?, "interface");
// Get value of an option, UCI's extended syntax is supported
assert_eq!(uci.get("network.@interface[0].proto")?, "static");
assert_eq!(uci.get("network.lan.proto")?, "static");
// Create a new section
uci.set("network.newnet", "interface")?;
uci.set("network.newnet.proto", "static")?;
uci.set("network.newnet.ifname", "en0")?;
uci.set("network.newnet.enabled", "1")?;
uci.set("network.newnet.ipaddr", "2.3.4.5")?;
uci.set("network.newnet.test", "123")?;
uci.delete("network.newnet.test")?;
// IMPORTANT: Commit or revert the changes
uci.commit("network")?;
uci.revert("network")?;
Dependencies
~0–2.3MB
~46K SLoC