1 unstable release
Uses old Rust 2015
0.1.0 | May 25, 2016 |
---|
#169 in #settings
20KB
417 lines
rust-jconfig
Configuration / settings backed by JSON files
Dashboard
Linux CI | Test Coverage | Crate | Documentation |
---|---|---|---|
Basic usage
use jconfig::Config;
fn main() {
// Load the config
let config = Config::load("my-config.json").unwrap();
// Try to get the field of type `Port`
println!("{}", config.get::<Port>().unwrap());
// Try to get the raw JSON for field "name"
println!("{}", config.get_raw("name").unwrap());
}
// your my-config.json
{
"port": 12345,
"name": "foo"
}
Don't forget to check out the examples
The config_field!()
macro
The crate defines a macro config_field!
that can simplify the consutrction of configuration field types.
#[macro_use]
extern crate jconfig;
config_field!{
/// Indicates some port of sorts...
///
/// This will show up in your documentation.
struct Port: u16,
key: "port",
default: 80 // this field is optional
}
License
Licensed under:
- Apache License, Version 2.0 - LICENSE-APACHE (source)
- MIT license - (LICENSE-MIT (source)
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Dependencies
~540KB
~12K SLoC