#[dynamic_config]Expand description
Turns a struct into a hot-reloadable configuration snapshot.
See the crate documentation for the full guide.
§Arguments
| Argument | Form | Requires | Default |
|---|---|---|---|
files | files = ["a.toml"] | one of files / name+paths | — |
name | name = "config" | paths | — |
paths | paths = ["/etc/app", "."] | name | — |
key | key = "db" | always | — |
env | env = "APP_" | no environment layer | |
nest | nest = "__" | env | "__" |
allow_empty_env | flag | env | off — FOO= is unset |
profile_env | profile_env = "APP_ENV" | no profile overlay | |
watch | flag | watch feature | off |
debounce | debounce = 250 | watch | 250 ms |
poll / poll_interval | flag / = 2000 | watch | native backend |
diff | flag | watch | off |
validate | flag | a validate() on the type | off |
save | flag | Self: Serialize | off |
async | flag | async feature | off |
One field attribute: #[config(secret)] generates a Debug that prints
*** for the marked fields, and forbids #[derive(Debug)] alongside it.
The README carries a section per argument, with an example and the reasoning behind each default.
§Requirements
The annotated struct must implement serde::Deserialize and be
Send + Sync + 'static. Type and const parameters are supported — those go
through a TypeId registry rather than a static, at a measured cost of
roughly 10 ns per read. A lifetime parameter is rejected at compile
time: the snapshot outlives every borrow that could name one.
Turns a struct into a hot-reloadable configuration snapshot.
Documented on the re-export in dynamic_config, which is where callers
should read it.