1 unstable release

0.1.5 May 22, 2021
0.1.4 May 22, 2021
0.1.0 Mar 25, 2021

#641 in Configuration

Download history 3/week @ 2024-01-22 53/week @ 2024-02-26 33/week @ 2024-03-04 9/week @ 2024-03-11 47/week @ 2024-03-18 10/week @ 2024-03-25 82/week @ 2024-04-01 38/week @ 2024-04-08 31/week @ 2024-04-15

161 downloads per month

MIT/Apache

380KB
13K SLoC

C 10K SLoC // 0.1% comments Rust 2K SLoC // 0.0% comments Shell 653 SLoC // 0.0% comments Lua 59 SLoC // 0.1% comments

rust-uci

crates.io

OpenWRT libuci bindings for the Rust programming language.

Documentation

License

libuci is licensed under GPLv2.

The files in this repository are licensed under either of

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–2MB
~40K SLoC