Universal Config
Universal Config is a library for Rust to simplify reading configuration files. It is able to automatically locate config files from standard locations, and has support for various file formats.
The crate does not offer a lot of functionality, leaving that to Serde and your implementation. Instead, it just deals with loading the file.
Currently, the following formats are supported:
- JSON
- YAML
- TOML
- Corn
Installation
Just add the crate:
By default, support for all languages is included.
You can enable/disable languages using feature flags. For example, in your Cargo.toml:
[]
= "0.1.0"
= false
= ["json", "toml"]
Example usage
use universal_config::ConfigLoader;
use serde::Deserialize;
#[derive(Deserialize)]
struct MyConfig {
foo: String,
}
fn main() {
let config: MyConfig = ConfigLoader::new("my-app").find_and_load().unwrap();
println!("{}", config.foo);
}
For more advanced usage, please check the docs.