Crates.io | universal-config |
lib.rs | universal-config |
version | 0.5.0 |
source | src |
created_at | 2023-03-12 20:16:31.706301 |
updated_at | 2024-03-30 15:31:24.498907 |
description | A library to simplify reading configuration files from various file formats. |
homepage | |
repository | |
max_upload_size | |
id | 808254 |
size | 29,901 |
Universal Config is a library for Rust to simplify reading and writing 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 and saving the file.
Currently, the following formats are supported:
serde_json
serde_yaml
toml
serde_xml_rs
libcorn
ron
Just add the crate:
cargo add universal-config
By default, support for all languages is included.
You can enable/disable languages using feature flags. For example, in your Cargo.toml
:
[dependencies.universal-config]
version = "0.1.0"
default-features = false
features = ["json", "toml"]
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.