id_effect_config 0.2.0

Effect.ts-style ConfigProvider + Figment/serde layers for the workspace `effect` crate
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//! [`MapConfigProvider`] with [`id_effect_config::config`] helpers (nested keys, defaults).

use id_effect_config::MapConfigProvider;
use id_effect_config::config;

fn main() -> Result<(), id_effect_config::ConfigError> {
  let p = MapConfigProvider::from_pairs([("SERVICE_HOST", "localhost"), ("SERVICE_NAME", "demo")]);

  let host = config::nested_string(&p, "SERVICE", "HOST")?;
  let name = config::nested_string(&p, "SERVICE", "NAME")?;
  let threads = config::with_default(config::nested_integer(&p, "SERVICE", "THREADS"), 4)?;

  println!("host={host} name={name} threads={threads}");
  Ok(())
}