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

  1. Create a configuration file (e.g., config.yaml).
  2. 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(): Returns true 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
Details
Cargo
2024-11-15 19:23:01 -08:00
17
MIT
4.5 KiB
Assets (1)
a0-0.0.4.crate 4.5 KiB
Versions (1) View all
0.0.4 2024-11-15