#[derive(Config)]
{
// Attributes available to this derive:
#[param]
}
Expand description
Derive config loading from multiple sources for a struct.
#[derive(Config)] generates a [server_less_core::config::Config]
implementation that loads values from defaults, TOML files, and environment
variables, with a configurable precedence order.
§Example
ⓘ
use server_less::Config;
#[derive(Config)]
struct AppConfig {
#[param(default = "localhost")]
host: String,
#[param(default = 8080)]
port: u16,
#[param(env = "DATABASE_URL")]
database_url: String,
timeout_secs: Option<u64>,
}
let cfg = AppConfig::load(&[
ConfigSource::Defaults,
ConfigSource::File("app.toml".into()),
ConfigSource::Env { prefix: Some("APP".into()) },
])?;§Field attributes
#[param(default = value)]— compile-time default; field becomes optional in sources#[param(env = "VAR")]— exact env var name (overrides{PREFIX}_{FIELD}generation)#[param(file_key = "a.b.c")]— dotted TOML key override (default: field name)#[param(help = "...")]— description used byconfig show --schemaand doc generators