2 unstable releases
Uses old Rust 2015
0.2.0 | Feb 11, 2018 |
---|---|
0.1.2 | Feb 10, 2018 |
#973 in Configuration
14KB
222 lines
A simple library for loading configuration files from disk. All that's
required is a struct with serde::Deserialize
and Default
implemented.
The configuration file is always assumed to be encoded in TOML format.
The library will load the first struct it finds in the following list:
./{name}
./{name}.toml
./.{name}
./.{name}.toml
~/.{name}
~/.{name}.toml
~/.config/{name}
~/.config/{name}.toml
~/.config/{name}/config
~/.config/{name}/config.toml
/etc/.config/{name}
/etc/.config/{name}.toml
/etc/.config/{name}/config
/etc/.config/{name}/config.toml
Usage
#[macro_use]
extern crate serde_derive;
extern crate loadconf;
/// Sample configuration
#[derive(Deserialize)]
struct Config {
/// Sample variable
var: String,
}
impl Default for Config {
fn default() -> Config {
Config { var: "Test configuration.".to_string() }
}
}
fn main() {
use loadconf::Load;
let config = Config::load("testcfg");
}
Dependencies
~0.9–1.6MB
~32K SLoC