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
```rust
extern crate serde_derive; extern crate loadconf;
/// Sample configuration
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");
} ```