Add uci-derive proc-macro crate with UciConfig and UciSection derive macros that generate UCI schema metadata from Settings structs. The schema maps UCI section types and option names to config-rs field paths. UciSource::from_schema() creates a source from the derived schema, mapping known UCI options to their Settings fields while preserving unknown options under raw UCI-derived paths.
30 lines
859 B
Rust
30 lines
859 B
Rust
// SPDX-FileCopyrightText: 2026-Present Nils Andreas Svee mailto:contact@lochnair.net (github @Lochnair)
|
|
//
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
|
pub(crate) struct UciOptionMapping {
|
|
pub(crate) uci_option: &'static str,
|
|
pub(crate) config_field: &'static str,
|
|
}
|
|
|
|
#[derive(Clone, Copy, Debug)]
|
|
pub(crate) struct UciSectionMapping {
|
|
/// UCI section type, corresponding to `@section_type[0]`.
|
|
pub(crate) uci_section: &'static str,
|
|
|
|
/// Top-level config-rs / Serde settings key.
|
|
pub(crate) config_section: &'static str,
|
|
|
|
pub(crate) options: &'static [UciOptionMapping],
|
|
}
|
|
|
|
pub(crate) trait UciSectionSchema {
|
|
const UCI_OPTIONS: &'static [UciOptionMapping];
|
|
}
|
|
|
|
pub(crate) trait UciConfigSchema {
|
|
const UCI_PACKAGE: &'static str;
|
|
const UCI_SECTIONS: &'static [UciSectionMapping];
|
|
}
|