# 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.
There are no `get_string("foo.bar")` dynamic accessors, and there will not be.
```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);
```
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).
- **Docs:** <https://config.rust.phpboyscout.uk>, with a
[tutorial](https://config.rust.phpboyscout.uk/tutorials/add-layered-configuration/),
[how-to guides](https://config.rust.phpboyscout.uk/how-to/),
[reference](https://config.rust.phpboyscout.uk/reference/),
and [what it does not do](https://config.rust.phpboyscout.uk/explanation/limitations/)
- **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) 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
[figment]: https://crates.io/crates/figment