rtb-config 0.6.5

Layered, typed configuration backed by figment. Part of the phpboyscout Rust toolkit.
Documentation

rtb-config

Part of the phpboyscout Rust toolkit: small, framework-free crates extracted from rust-tool-base.

Typed, layered configuration backed by figment. Declare a serde::Deserialize struct, layer embedded defaults, user files, and prefixed env vars over it, and read atomically swapped Arc snapshots. There are no get_string("foo.bar") dynamic accessors, and there will not be.

use rtb_config::Config;
use serde::Deserialize;

#[derive(Deserialize, Default)]
struct MyConfig { host: String, port: u16 }

let cfg = Config::<MyConfig>::builder()
    .embedded_default("host: localhost\nport: 8080\n")
    .env_prefixed("MYTOOL_")
    .build()?;

let current = cfg.get();
assert_eq!(current.port, 8080);

Two optional features, both off by default: hot-reload (a debounced file watcher that reloads on change) and mutable (Config::schema() and Config::write(), for config set / schema / validate style subcommands).

Development

just ci runs the full local gate (fmt, clippy, nextest, doc, deny) with every feature enabled, as the merge-request pipeline does. Tests include a cucumber BDD suite (tests/bdd.rs). Releases are cut by colophon from Conventional Commits, so do not tag manually.

License

MIT