explicon

Crates.ioexplicon
lib.rsexplicon
version0.2.0
created_at2025-04-29 08:32:54.395426+00
updated_at2025-04-29 14:28:28.371868+00
descriptionConfiguration without surprises
homepage
repositoryhttps://github.com/metdxt/explicon
max_upload_size
id1653302
size15,389
METDXT (metdxt)

documentation

README

Explicon

Explicon is a tiny utility crate for removing surprises from configuration.

Have you ever been annoyed that when you set some value in your config.toml if silently got overriden by some environment variable you weren't even aware of?

This crate addresses exactly that problem, by making configuration EXPLICIT.

Example

// Hypothetical other config crate (pseudo-code)

#[derive(Debug, FancyConfig, serde::Deserialize, serde::Serialize)]
struct MyAwesomeConfig {
    host: String,
    port: u16
}

let config = MyAwesomeConfig::from_file("config.toml")
    .from_env() // Silently overrides values in config.toml, BAD!

In contrast:

// Explicon
use explicon::Sourced;

#[derive(Debug, serde::Deserialize, serde::Serialize)]
struct MyAwesomeConfig {
    host: Sourced<String>
    port: Sourced<u16>
}


let config: MyAwesomeConfig = toml::from_str(r#"
    host = { env = "MY_ENV_VAR_FOR_HOST" }
    port = 8080
"#).unwrap();

let host: String = config.host.resolve().unwrap() // Get actual value from config
let port: u16 = config.port.resolve().unwrap_or(3000)

As you can see, using explicon::Sourced in your configuration allows you to see exactly where values come from only from your config.toml file, no need to parse actual source of your program to figure out that your host is actually overriden by some MY_COOL_APP_HOST.

No hidden flow.

Commit count: 4

cargo fmt