adotenv-process
Explicit process-environment mutation for
adotenv loaded environments.
use load_cascade;
use apply;
let loaded = load_cascade?;
// The caller must guarantee no concurrent process-environment access.
unsafe ;
apply takes a LoadedEnvironment from the adotenv load feature. It
validates every key and value before the first mutation and returns an
ApplyError for an empty key, a key that contains NUL or =, or a value that
contains NUL. On Windows it also rejects keys that differ only by case and
values longer than 32,767 UTF-16 code units. It sets only keys from the loaded
environment, removes nothing and cannot roll changes back. The process environment is global, so the caller owns
the concurrency guarantee.
validate runs the same checks without changing anything. validate_compact
and apply_compact provide the same validation and process-mutation semantics
for CompactValues (such as values returned by load_cascade_values_compact
or load_values_compact).
Prefer passing LoadedEnvironment::values() to a child process, or reading them
directly, when mutation is not required. See the
process environment guide.
This is the only published workspace crate with an unsafe public API. The core
adotenv crate forbids unsafe code. The crate needs Rust 1.81 or later.