Expand description
Lightweight settings helpers: a secret-masking string newtype and a precedence-based value loader.
This mirrors upstream’s _settings.py, which replaced a
pydantic-settings-based AFBaseSettings with a function-based loader
(load_settings) plus a repr-masking SecretString. Rather than port
the Python TypedDict-driven schema loader (which leans on runtime
reflection that has no idiomatic Rust equivalent), this module provides
the two reusable primitives:
SecretString— aStringnewtype whoseDebug/Displayimpls mask the value so secrets never leak into logs, while still (de)serializing to the real value and round-tripping throughserde_json.load_setting— a single-value loader implementing the same precedence as upstream’sload_settings: explicit override, then a.envfile, then the process environment, then a default.
§Example
use agent_framework_core::settings::SecretString;
let key = SecretString::new("sk-super-secret");
assert_eq!(format!("{key}"), "***");
assert_eq!(format!("{key:?}"), "SecretString(\"***\")");
assert_eq!(key.expose_secret(), "sk-super-secret");Structs§
- Secret
String - A string wrapper that masks its value when printed via
DebugorDisplay, to prevent secrets (API keys, tokens, passwords, …) from accidentally ending up in logs or error messages.
Functions§
- load_
setting - Resolve a single setting value using the same precedence as upstream’s
load_settings: