pf_config
pf_config - Layered configuration loader
Sources (in precedence, low -> high):
- Cargo.toml section (feature: cargo-toml)
- JSON files
- .env (feature: dotenv)
- OS environment variables
This crate is target-agnostic by design; initial implementation is native-only.
Structs
Section titled “Structs”LoadOptions
Section titled “LoadOptions”Fields
| Field | Type | Description |
|---|---|---|
json_paths | Vec<PathBuf> | |
enable_dotenv | bool | |
env_prefix | Option<&''static str> | |
env_key_transform | EnvKeyTransform | |
required | bool |
ConfigError
Section titled “ConfigError”Variants
| Variant | Description |
|---|---|
Io(Error) | |
JsonParse(serde_json::Error) | |
TypeMismatch(serde_json::Error) | |
NotFound(String) |
EnvKeyTransform
Section titled “EnvKeyTransform”Variants
| Variant | Description |
|---|---|
DoubleUnderscoreToNested | Convert PREFIX_A__B__C to nested {"a": {"b": {"c": value}}} |
Functions
Section titled “Functions”load_config_untyped
Section titled “load_config_untyped”fn load_config_untyped(opts: LoadOptions) -> Result<serde_json::Value, ConfigError>load_config
Section titled “load_config”fn load_config<T>(opts: LoadOptions) -> Result<T, ConfigError>