| Crates.io | a0 |
| lib.rs | a0 |
| version | 0.0.4 |
| created_at | 2024-09-29 04:48:50.995932+00 |
| updated_at | 2024-09-29 06:05:10.592655+00 |
| description | generate structs and their values from external data |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1390594 |
| size | 13,245 |
A Rust procedural macro for automatically generating structs from configuration files (JSON, YAML, TOML).
config.yaml).generate attribute 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);
}
new(): Creates a new instance with values from the file.default(): Creates a new instance no values from the file.is_empty(): Returns true if all fields are default values.