Skip to main content

load_setting

Function load_setting 

Source
pub fn load_setting(
    key: &str,
    override_value: Option<String>,
    default: Option<String>,
) -> Option<String>
Expand description

Resolve a single setting value using the same precedence as upstream’s load_settings:

  1. override_value — an explicit value supplied by the caller (e.g. a constructor argument).
  2. A ./.env file in the current working directory, if present, looked up by key.
  3. The key process environment variable.
  4. default.

Returns None if none of the sources produced a value.

This is a dependency-free, single-key analogue of upstream’s TypedDict-driven load_settings(); callers needing to resolve several related fields can call this once per field.