figen
figen is a Rust library for generating strongly-typed configuration bindings and registries from a compact declarative schema.
It is designed to simplify configuration management, primarily for embedded development, where parsing and wiring configuration keys by hand becomes repetitive and error-prone.
Why this project exists
Embedded firmware often needs:
- Static, known-at-compile-time configuration structures
- Reliable parsing from key-value sources (files, NVS, RPC backends, etc.)
- A machine-readable registry that clients can fetch to discover capabilities
figen reduces boilerplate by generating the config structs, binders, defaults, and registry metadata from a single source of truth.
Key features
- Works in both
stdandno_stdenvironments - Declarative config schema via
config_registry! - Generated strongly-typed config structs
- Default values and optional fields
- Nested keys and indexed-array key support
- Generated registry metadata with versioning
- Custom property types via
TryFrom<&str>+#[derive(ConfigBinder)]
Quick example
use config_registry;
config_registry!;
// Generated:
// - AppConfig (root config struct)
// - APP_CONFIG_REGISTRY (registry static)
Loading:
let loader = new; // implement figen::loader::PropertyLoader
let cfg: AppConfig = load_config?;
Multiple registries (example)
You can define independent registries in separate modules and avoid naming collisions:
// app::APP_CONFIG_REGISTRY
// board::BOARD_CONFIG_REGISTRY
Custom types
use config_registry;
;
config_registry!;
Feature flags
std: enablesstdsupport and lazy static registry for runtime-friendly environmentsserde: enables serde serialization support for generated registry/config metadata
Common combinations:
--no-default-features--no-default-features --features serde--no-default-features --features std--no-default-features --features std --features serde
Project status
Early-stage and evolving. Breaking API changes are still possible while the API is being shaped.
Contributing
Issues and pull requests are welcome. If you propose API changes, include motivation and expected embedded/firmware workflow impact.
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT license (LICENSE-MIT)
at your option.