Skip to content

Configuration / Settings backed by JSON files

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

icorderi/rust-jconfig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rust-jconfig

Configuration / settings backed by JSON files

Dashboard

Linux CI Test Coverage Crate Documentation
Build Status Coverage Status Crate Docs

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:

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.

About

Configuration / Settings backed by JSON files

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages