pub struct SourceChain<'src>(/* private fields */);Expand description
An ordered chain of ConfigSources. Assembly walks the chain in order;
within one source its env var is checked before its TOML value; the first
source to answer either wins for that field. Build one with
SourceChain::new and SourceChain::push, then pass it to
EnvConfig::assemble.
Implementations§
Source§impl<'src> SourceChain<'src>
impl<'src> SourceChain<'src>
Sourcepub fn push(self, source: &'src dyn ConfigSource) -> Self
pub fn push(self, source: &'src dyn ConfigSource) -> Self
Appends source to the end of the chain (lowest priority so far).
Sourcepub fn iter(&self) -> impl Iterator<Item = &'src dyn ConfigSource> + '_
pub fn iter(&self) -> impl Iterator<Item = &'src dyn ConfigSource> + '_
Iterates the chain in priority order (first pushed, checked first).
Sourcepub fn toml_value(&self, key: &str) -> Option<&Value>
pub fn toml_value(&self, key: &str) -> Option<&Value>
The first source in the chain that has a TOML value for key, if
any. A default_fn uses this to derive its field from a sibling
field’s raw value (for example deriving auth_url from api_url)
without duplicating the chain-walk resolve_field already does.
Sourcepub fn env_name(&self) -> Option<&str>
pub fn env_name(&self) -> Option<&str>
The environment name of the first source in the chain that has one
(see ConfigSource::env_name), if any. A default_fn uses this to
derive its field from the environment’s own identity (for example
account.{name}.example.com).