LiveSettings

Derive Macro LiveSettings 

Source
#[derive(LiveSettings)]
Expand description

Derive macro that generates a LiveSettings struct for hot-reloading configuration. Requires Settings to be derived on the same struct first.

§Generated struct

Creates a LiveSettings struct with:

  • new(flags: SettingsFlags, update_freq: Duration) -> Result<Self> - constructor
  • config(&self) -> ConfigStruct - returns current config, reloading if file changed
  • initial(&self) -> ConfigStruct - returns initial config without reload check

§Example

#[derive(LiveSettings, MyConfigPrimitives, Settings)]
pub struct AppConfig {
    pub host: String,
    pub port: u16,
}

// Usage:
let live = LiveSettings::new(cli.settings, Duration::from_secs(5))?;
let config = live.config(); // Hot-reloads if file changed