Crates.io | serfig |
lib.rs | serfig |
version | 0.1.0 |
source | src |
created_at | 2022-04-19 06:35:04.454859 |
updated_at | 2023-03-15 07:59:58.004417 |
description | Layered configuration system built upon serde |
homepage | |
repository | https://github.com/Xuanwo/serfig |
max_upload_size | |
id | 570190 |
size | 47,397 |
Layered configuration system built upon serde
use serde::{Deserialize, Serialize};
use serfig::collectors::{from_env, from_file, from_self};
use serfig::parsers::Toml;
use serfig::Builder;
#[derive(Debug, Serialize, Deserialize, PartialEq, Default)]
#[serde(default)]
struct TestConfig {
a: String,
b: String,
c: i64,
}
fn main() -> anyhow::Result<()> {
let builder = Builder::default()
.collect(from_env())
.collect(from_file(Toml, "config.toml"))
.collect(from_self(TestConfig::default()));
let t: TestConfig = builder.build()?;
println!("{:?}", t);
Ok(())
}
Check out the CONTRIBUTING.md guide for more details on getting started with contributing to this project.
Submit issues for bug report or asking questions in discussion.
This project is highly inspired by config-rs