For converting config files to Rust structs, so they can be compiled in to a binary. Allows for using config files in no-std no-alloc environments.
Work in progress.
Initially supports YAML.
Feature flags
- "relative-to-macro": requires nightly, allows for paths relative to the macro
invocation to be used in the
config_to_rsattribute instead of paths relative to the crate root. This is useful if you have a complex project structure where you have multiple local crates in a single cargo project.
Example
Given a YAML file:
parsing: "working"
age: 22
enabled: true
time: 22.34
recurse:
thing: 1
recurse:
thing: 3
array:
empty_array:
array_of_arrays:
-
-
array_of_objects:
- name: "a"
age: 1
- name: "b"
age: 2
- name: "c"
age: 3
and a Rust struct:
;
the macro will generate the following Rust code:
pub const CONFIG: Config = Config ;
Which then allows for accessing the config values as you would any other Rust struct:
// items in a hashmap
assert_eq!;
// items in a list
assert_eq!;
// nested hashmaps
assert_eq!;