1 unstable release
Uses old Rust 2015
0.1.0 | Mar 14, 2018 |
---|
#661 in Configuration
3KB
Configurator
Configurator makes statically-typed configuration for Rust easy.
Example
main.rs:
#[macro_use]
extern crate serde_derive;
extern crate serde_json;
#[macro_use]
extern crate configurator;
use std::fs::File;
use std::io::prelude::*;
#[derive(Debug, Deserialize)]
struct Testing {
a: String
}
fn main() {
match load_config!(Testing, "config.json") {
Ok(c) => println!("{:?}", c),
Err(e) => println!("Encountered an error: {}", e)
}
}
config.json:
{
"a": "Testing all the things"
}
Result:
Testing { a: "Testing all the things" }
Unfortunately, we currently rely on serde
for JSON-to-file conversions.
Dependencies
~0.3–0.8MB
~19K SLoC