Skip to main content

dynamic_config

Attribute Macro dynamic_config 

Source
#[dynamic_config]
Expand description

Turns a struct into a hot-reloadable configuration snapshot.

See the crate documentation for the full guide.

The attribute takes no arguments: it declares that the type is a configuration, and generates its storage and surface. Where the configuration comes from is stated on the Builder the generated builder(key) returns — see the front page for the shape, and the book’s reference for every method. An argument between the parentheses is a compile error whose message maps each old argument to its builder method.

One field attribute: #[config(secret)] generates a Debug that prints *** for the marked fields, forbids #[derive(Debug)] alongside it, keeps the field out of the redacted cache, and marks it writeOnly in the schema.

§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.