Available on crate feature
config only.Expand description
Configuration management with 8-layer cascade.
Provides a hierarchical configuration system matching hyperi-pylib (Python) and hyperi-golib (Go). Configuration is loaded from multiple sources with clear priority ordering.
§Cascade Priority (highest to lowest)
- CLI arguments (via clap integration)
- Environment variables (with configurable prefix)
.envfile (loaded via dotenvy)- PostgreSQL (optional, via
config-postgresfeature) settings.{env}.yaml(environment-specific)settings.yaml(base settings)defaults.yaml- Hard-coded defaults
§How .env Files Work in the Cascade
dotenvy::dotenv() loads .env into the process environment, so .env
values are read at layer 2 alongside real env vars. Real env vars win:
dotenvy does NOT overwrite existing variables.
§Environment Variable Naming
Use the env_compat module for standardised environment variable names
with legacy alias support and deprecation warnings.
§Example
use hyperi_rustlib::config::{self, ConfigOptions};
// Initialise with env prefix
config::setup(ConfigOptions {
env_prefix: "MYAPP".into(),
..Default::default()
}).unwrap();
// Access configuration
let cfg = config::get();
let host = cfg.get_string("database.host").unwrap_or_default();
let port = cfg.get_int("database.port").unwrap_or(5432);Modules§
- env_
compat - Environment variable compatibility layer.
- flat_
env - Flat environment variable override helpers.
- registry
- Reflectable configuration registry.
- reloader
config-reload - Universal configuration reloader for DFE components.
- sensitive
- Re-exports
SensitiveStringfrom the crate root for backward compatibility. - shared
config-reload - Generic thread-safe shared configuration with version tracking.
Structs§
- Config
- Configuration manager wrapping Figment.
- Config
Options - Configuration options.
Enums§
- Config
Error - Configuration errors.