Crates.io | loadconf |
lib.rs | loadconf |
version | 0.2.0 |
source | src |
created_at | 2018-02-10 05:55:05.345321 |
updated_at | 2018-02-11 12:09:59.680666 |
description | Library for loading configuration files quickly. |
homepage | |
repository | https://github.com/xurtis/loadconf |
max_upload_size | |
id | 50440 |
size | 14,173 |
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
#[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");
}