# rtb-config
> Part of the [phpboyscout Rust toolkit](https://rust.phpboyscout.uk) —
> small, framework-free crates extracted from
> [rust-tool-base](https://gitlab.com/phpboyscout/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 —
no `get_string("foo.bar")` dynamic accessors, ever.
```rust
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);
```
Optional features: `hot-reload` (debounced file watcher that reloads on
change) and `mutable` (`Config::schema()` / `Config::write()` for
`config set / schema / validate` style subcommands).
- **Docs:** <https://config.rust.phpboyscout.uk>
- **API reference:** <https://docs.rs/rtb-config>
- **Crate:** <https://crates.io/crates/rtb-config>
## Development
`just ci` runs the full local gate (fmt, clippy, nextest, doc, deny).
Tests include a cucumber BDD suite (`tests/bdd.rs`). Releases are cut by
release-plz from Conventional Commits — do not tag manually.
## License
MIT
[figment]: https://crates.io/crates/figment