4 releases
| 0.0.4 | Sep 29, 2024 |
|---|---|
| 0.0.3 | Sep 29, 2024 |
| 0.0.2 | Sep 29, 2024 |
| 0.0.1 | Sep 29, 2024 |
#36 in Procedural macros
10KB
167 lines
A Rust procedural macro for automatically generating structs from configuration files (JSON, YAML, TOML).
Example Usage
- Create a configuration file (e.g.,
config.yaml). - Use the
generateattribute macro:
server:
port: 8080
features:
- logging
- authentication
Generate and use the struct:
#[generate("config.yaml")]
struct AppConfig;
fn main() {
let config = AppConfig::new();
println!("Server port: {}", config.server.port);
println!("Features: {:?}", config.features);
}
API
new(): Creates a new instance with values from the file.default(): Creates a new instance no values from the file.is_empty(): Returnstrueif all fields are default values.
Dependencies
~1.3–2.4MB
~48K SLoC