themackabu/a0 Verified Publisher
By themackabu • Updated about 2024-11-15 19:23:01 -08:00
Installation
[registries.pkgci-themackabu]
index = "sparse+ "
cargo add a0@0.0.4 --registry "pkgci-themackabu"
About this package
generate structs and their values from external data
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
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);
}
API
new()
: Creates a new instance with values from the file.default()
: Creates a new instance no values from the file.is_empty()
: Returnstrue
if all fields are default values.
Dependencies
ID | Version |
---|---|
proc-macro2 | ^1.0.86 |
quote | ^1.0.37 |
serde_json | ^1.0.128 |
serde_yaml | ^0.9.34 |
syn | ^2.0.79 |
toml | ^0.8.19 |