pub trait EnvSource: Send + Sync {
// Required method
fn var(&self, name: &str) -> Option<String>;
// Provided method
fn vars(&self) -> Vec<(String, String)> { ... }
}Expand description
Read-only lookup for an environment variable name.
Production code wires up ProcessEnvSource (which calls
std::env::var). Tests wire up MapEnvSource to drive
deterministic branches without mutating the process env.
Required Methods§
Provided Methods§
Sourcefn vars(&self) -> Vec<(String, String)>
fn vars(&self) -> Vec<(String, String)>
Snapshot every (name, value) pair this source can enumerate.
Callers that need to scan the whole env (e.g. the determinism
harness’s Windows inherit-everything pass, which drops a
credential deny-list out of the host env) use this instead of
std::env::vars() so a test can inject a closed map of fixture
entries. The default implementation returns an empty Vec so
any source that only supports point lookups (a stub, a small
fixture) stays usable for var(...)-only call sites without
extra boilerplate.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".