feat(uci): add generalized UCI configuration source
Introduce the UciSource abstraction as a config-rs Source that reads UCI packages and maps them into the configuration tree. Supports package selection, required/optional behavior, and custom config/save directories. Move rust-uci dependency to cfg(unix) to enable UCI support on all Unix systems for development and testing, while Linux/OpenWrt remains the production-supported platform.
This commit is contained in:
7 files changed
+256
-6
No files matched your search
@@ -9,6 +9,9 @@ use serde::{Deserialize, Deserializer, de};
|
||||
use std::fmt::{self, Display};
|
||||
use std::str::FromStr;
|
||||
|
||||
#[cfg(all(feature = "uci", unix))]
|
||||
use crate::platform::unix::uci::UciSource;
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
pub enum MeasurementType {
|
||||
Icmp = 1,
|
||||
@@ -76,6 +79,9 @@ impl Settings {
|
||||
pub(crate) fn load() -> Result<Self, ConfigError> {
|
||||
let builder = Config::builder();
|
||||
|
||||
#[cfg(all(feature = "uci", unix))]
|
||||
let builder = builder.add_source(UciSource::new(["sqm-autorate-rust"]).required(false));
|
||||
|
||||
#[cfg(feature = "toml")]
|
||||
let builder = builder.add_source(
|
||||
config::File::with_name("/etc/sqm-autorate-rust/config.toml").required(false),
|
||||
|
||||
Reference in new issue
Block a user