pub trait EnvSource {
// Required method
fn var(&self, key: &str) -> Option<String>;
// Provided methods
fn var_any(&self, keys: &[&str]) -> Option<String> { ... }
fn var_triple(
&self,
key: &str,
file_key: &str,
command_key: &str,
) -> SecretTriple { ... }
}Expand description
A read-only view of environment variables.
Implemented by SystemEnv (the real process environment) in production
and by an in-memory map in tests, so env-parsing boundaries can be tested
without mutating the process-global environment.
Required Methods§
Provided Methods§
Sourcefn var_any(&self, keys: &[&str]) -> Option<String>
fn var_any(&self, keys: &[&str]) -> Option<String>
Returns the first set value among keys, in order.
Sourcefn var_triple(
&self,
key: &str,
file_key: &str,
command_key: &str,
) -> SecretTriple
fn var_triple( &self, key: &str, file_key: &str, command_key: &str, ) -> SecretTriple
Returns key, file_key and command_key from the same layer,
for the secret resolver’s NAME/NAME_FILE/NAME_COMMAND triples
(crate::utils::secret_env).
A single-layer source returns all three lookups. A layered source
(settings.json’s SettingsEnv)
overrides this to return the triple from the highest-precedence layer
that sets any member, so a conflict is only ever detected within one
layer.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl<T: EnvSource + ?Sized> EnvSource for &T
&T is an EnvSource whenever T is, so callers can pass &SystemEnv
or &map_env to functions taking &impl EnvSource without ceremony.
impl<T: EnvSource + ?Sized> EnvSource for &T
&T is an EnvSource whenever T is, so callers can pass &SystemEnv
or &map_env to functions taking &impl EnvSource without ceremony.