Skip to content

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.

Fields

FieldTypeDescription
json_pathsVec<PathBuf>
enable_dotenvbool
env_prefixOption<&''static str>
env_key_transformEnvKeyTransform
requiredbool

Variants

VariantDescription
Io(Error)
JsonParse(serde_json::Error)
TypeMismatch(serde_json::Error)
NotFound(String)

Variants

VariantDescription
DoubleUnderscoreToNestedConvert PREFIX_A__B__C to nested {"a": {"b": {"c": value}}}
fn load_config_untyped(opts: LoadOptions) -> Result<serde_json::Value, ConfigError>
fn load_config<T>(opts: LoadOptions) -> Result<T, ConfigError>