| Crates.io | configurator |
| lib.rs | configurator |
| version | 0.1.0 |
| created_at | 2018-03-14 07:58:04.315426+00 |
| updated_at | 2018-03-14 07:58:04.315426+00 |
| description | Statically-Typed Configuration Structs / Files for Rust. |
| homepage | |
| repository | https://github.com/innectic/configurator |
| max_upload_size | |
| id | 55500 |
| size | 3,615 |
Configurator makes statically-typed configuration for Rust easy.
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.