configit

Crates.ioconfigit
lib.rsconfigit
version0.3.1
sourcesrc
created_at2022-01-16 03:27:03.00135
updated_at2022-01-23 10:57:10.097422
descriptionZero-boilerplate configuration management in Rust
homepagehttps://github.com/ltoddy/configit
repositoryhttps://github.com/ltoddy/configit
max_upload_size
id514618
size19,495
LiuTao (ltoddy)

documentation

https://docs.rs/configit

README

configit

Zero-boilerplate configuration management in Rust

Installation

cargo add configit

usage

config.toml

host = "127.0.0.1"
port = 8888

src/main.rs

use serde::{Deserialize, Serialize};
use configit::Loader;

#[derive(Debug, Deserialize)]
pub struct AppConfig {
    pub host: String,
    pub port: u16,
}

fn main() {
    let config = AppConfig::load("config.toml").expect("couldn't load `config.toml` file");
    println!("config: {config:?}"); // config: AppConfig { host: "127.0.0.1", port: 8888 }
}
Commit count: 8

cargo fmt