Skip to main content

explain

Function explain 

Source
pub fn explain(spec: &LoadSpec<'_>, path: &str) -> Result<Explanation, Error>
Expand description

Explains path: every configured layer’s answer, not just the winner’s.

The rendered Explanation contains values — that is its point; you asked. It is the one diagnostic in this crate that does, so treat its output accordingly. A path the caller knows to be sensitive goes through Explanation::redacted; the generated explain() does that for #[config(secret)] fields automatically.

§Errors

Whatever reading the sources reports — the same failures a load would hit.

§Example

use dynamic_config::{explain, Format, LoadSpec, Source};

let sources = [Source::inline(r#"{"db": {"port": 5432}}"#, Format::Json)];
let explanation = explain(&LoadSpec::new("db", &sources), "port")
    .expect("the inline document is well formed");

assert_eq!(explanation.winner().unwrap().layer, "file");
println!("{explanation}");