MCPcopy Index your code
hub / github.com/SergioBenitez/Figment

github.com/SergioBenitez/Figment @v0.10.18

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.10.18 ↗ · + Follow
346 symbols 710 edges 30 files 103 documented · 30%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

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"] }

Third-Party Providers

The following external libraries implement Figment providers:

Wraps existing providers. For any key ending in _FILE (configurable), emits a key without the _FILE suffix with a value corresponding to the contents of the file whose path is the original key's value.

Please submit a pull request to add your library to this list.

License

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

  • Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
  • MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)

Extension points exported contracts — how you extend this code

Provider (Interface)
Trait implemented by configuration source providers. For an overview of built-in providers, see the [top-level docs](cr [6 …
src/provider.rs
Magic (Interface)
Marker trait for "magic" values. Primarily for use with [`Either`]. [2 implementers]
src/value/magic.rs
Coalescible (Interface)
(no doc) [3 implementers]
src/coalesce.rs
Format (Interface)
Trait implementable by text-based [`Data`] format providers. Instead of implementing [`Provider`] directly, types that
src/providers/data.rs
Interpreter (Interface)
(no doc) [2 implementers]
src/value/de.rs

Core symbols most depended-on inside this repo

merge
called by 34
src/figment.rs
map
called by 34
src/providers/env.rs
iter
called by 22
src/providers/env.rs
as_str
called by 19
src/profile.rs
collect
called by 14
src/profile.rs
tag
called by 12
src/value/value.rs
retagged
called by 11
src/error.rs
next
called by 10
src/value/tag.rs

Shape

Method 245
Class 42
Function 38
Enum 16
Interface 5

Languages

Rust100%

Modules by API surface

src/value/magic.rs36 symbols
src/value/de.rs33 symbols
src/figment.rs28 symbols
src/value/ser.rs25 symbols
src/error.rs24 symbols
src/value/value.rs21 symbols
src/value/tag.rs20 symbols
src/providers/env.rs20 symbols
src/profile.rs20 symbols
src/providers/data.rs17 symbols
src/metadata.rs14 symbols
src/jail.rs14 symbols

For agents

$ claude mcp add Figment \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact