Skip to content

A hierarchical configuration library so con-free, it's unreal.

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

rocket-org/figment

This branch is 59 commits behind SergioBenitez/Figment:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

a40e81b · Jul 17, 2021

History

49 Commits
Feb 14, 2021
Oct 16, 2020
Jul 17, 2021
Apr 2, 2021
Oct 12, 2020
Oct 10, 2020
Jun 25, 2021
Oct 10, 2020
Oct 10, 2020
Dec 22, 2020
Oct 10, 2020

Repository files navigation

Figment   ci.svg crates.io docs.rs

Figment is a semi-hierarchical configuration library for Rust so con-free, it's unreal.

use serde::Deserialize;

use figment::{Figment, providers::{Format, Toml, Json, Env}};

#[derive(Deserialize)]
struct Package {
    name: String,
    authors: Vec<String>,
    publish: Option<bool>,
    // ... and so on ...
}

#[derive(Deserialize)]
struct Config {
    package: Package,
    rustc: Option<String>,
    // ... and so on ...
}

let config: Config = Figment::new()
    .merge(Toml::file("Cargo.toml"))
    .merge(Env::prefixed("CARGO_"))
    .merge(Env::raw().only(&["RUSTC", "RUSTDOC"]))
    .join(Json::file("Cargo.json"))
    .extract()?;

See the documentation for a detailed usage guide and information.

Usage

Add the following to your Cargo.toml, enabling the desired built-in providers:

[dependencies]
figment = { version = "0.10", features = ["toml", "env"] }

License

Figment is licensed under either of the following, at your option:

About

A hierarchical configuration library so con-free, it's unreal.

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 99.1%
  • Shell 0.9%