Configuration
siderite::config (crate siderite-config) loads Settings with
figment.
Sources and precedence
Section titled “Sources and precedence”Lowest to highest:
- compiled defaults
- TOML files (
filefor a required file,file_optionalfor an optional one) - the environment
- programmatic overrides (
set)
Overrides always win, whatever order the builder calls come in. Files and environment sources merge in the order they are added.
use siderite::config::{ConfigBuilder, load};
// siderite.toml (optional) + SIDERITE_* + DATABASE_URL / ADDRlet settings = load()?;
let settings = ConfigBuilder::new() .file("config/app.toml") .env_prefix("MYAPP_") .set("app.debug", true) .build()?;Environment keys use __ for nesting once the prefix is stripped:
SIDERITE_DATABASES__ANALYTICS__URL sets databases.analytics.url.
env_prefix also maps two unprefixed aliases, and prefixed keys win over
them:
| Variable | Key |
|---|---|
DATABASE_URL |
databases.default.url |
ADDR |
server.addr |
extract::<T>() deserializes the same merged tree into your own type, so
application-specific sections can live next to the built-in ones.
Settings
Section titled “Settings”secret_key = "change-me"
[app]name = "blog" # default "siderite"debug = false
[server]addr = "0.0.0.0:8080" # default "127.0.0.1:8000"
[databases.default]url = "postgres://app:pw@db/app"max_connections = 10
[databases.analytics]url = "sqlite://analytics.db"
[cache]url = "redis://cache:6379/0"max_entries = 1024
[log]level = "info"json = falseSecrets
Section titled “Secrets”Database URLs, cache.url, and secret_key are Secret<String>.
DebugandDisplayprint[REDACTED]. Callexpose()to read the value.- There is no
Serializeimpl, so a secret cannot be written back out by accident. ConfigErrormessages never include the value of a secret-looking key (url,password,token,secret_key,api_key, …).
Tracing and the CLI
Section titled “Tracing and the CLI”init_tracing(&settings.log)installs a subscriber.RUST_LOGoverrideslog.level, andlog.jsonselects JSON output. See Observability.CliSettings::from(&settings)hands the address and database URLs toAppCli. See CLI.