5 releases

0.1.0 Mar 15, 2023
0.0.3 Oct 26, 2022
0.0.2 May 18, 2022
0.0.1 Apr 23, 2022
0.0.0 Apr 19, 2022

#1275 in Encoding

Download history 2047/week @ 2024-07-21 1713/week @ 2024-07-28 1897/week @ 2024-08-04 1486/week @ 2024-08-11 1491/week @ 2024-08-18 951/week @ 2024-08-25 1547/week @ 2024-09-01 1195/week @ 2024-09-08 825/week @ 2024-09-15 1036/week @ 2024-09-22 328/week @ 2024-09-29 1125/week @ 2024-10-06 932/week @ 2024-10-13 1149/week @ 2024-10-20 1459/week @ 2024-10-27 996/week @ 2024-11-03

4,726 downloads per month
Used in blooming

Apache-2.0

34KB
683 lines

serfig   Build Status Latest Version

Layered configuration system built upon serde

Quick Start

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(())
}

Contributing

Check out the CONTRIBUTING.md guide for more details on getting started with contributing to this project.

Getting help

Submit issues for bug report or asking questions in discussion.

Acknowledgment

This project is highly inspired by config-rs

License

Licensed under Apache License, Version 2.0.

Dependencies

~2MB
~34K SLoC