config_struct
This is a library for converting config files into matching source files at build time.
Usage
This library is intended to be used in a build.rs
file, so it needs to be added to [build-dependencies]
.
[]
= "~0.1.0"
= ["toml-parsing"]
By default, config_struct
is markup-language-agnostic, so include the relevant feature for whatever language your config file is written in. Choices are:
json-parsing
ron-parsing
toml-parsing
yaml-parsing
Now in your build.rs
file, add code like the following:
extern crate config_struct;
This will take the following config.toml
file:
= "Config name"
... and generate the following config.rs
file:
use Cow;
pub const CONFIG: Config = Config ;