pub trait EnvSource {
// Required method
fn var(&self, key: &str) -> Option<String>;
// Provided methods
fn var_any(&self, keys: &[&str]) -> Option<String> { ... }
fn var_pair(
&self,
key: &str,
file_key: &str,
) -> (Option<String>, Option<String>) { ... }
}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_pair(
&self,
key: &str,
file_key: &str,
) -> (Option<String>, Option<String>)
fn var_pair( &self, key: &str, file_key: &str, ) -> (Option<String>, Option<String>)
Returns key and file_key from the same layer, for the secret
resolver’s NAME/NAME_FILE pairs
(crate::utils::secret_env).
A single-layer source returns both lookups. A layered source
(settings.json’s SettingsEnv)
overrides this to return the pair from the highest-precedence layer
that sets either, 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.