Skip to main content

load_app_config

Function load_app_config 

Source
pub fn load_app_config<T: DeserializeOwned>(section_name: &str) -> Result<T>
Expand description

Load an app-specific configuration section from atrg.toml.

This allows apps to define custom [section_name] blocks in atrg.toml and deserialize them into typed structs, with automatic environment variable overrides using the {PREFIX}_FIELD convention.

§Examples

#[derive(serde::Deserialize)]
struct MyAppConfig {
    database_url: String,
    admin_dids: Vec<String>,
}

let config: MyAppConfig = atrg_core::config::load_app_config("myapp")?;

Fields can be overridden by env vars: set MYAPP_DATABASE_URL to override [myapp] database_url. The prefix is derived by uppercasing the section name.