std::env::set_var is marked unsafe in the Rust 2024 edition. set_var is used in majority of functions in v0.15.
This PR introduces a non-modifying API for loading of environment variables. Modifying of the environment is also supported with improved ergonomics limiting the use of unsafe.
introduction of EnvLoader
with_path and with_reader entry points with deferred IO
supports optional loading and override using EnvSequence
non-modifying API with load
unsafe modifying API with load_and_modify
return type EnvMap is a HashMap newtype with EnvMap::var
load attribute macro
compatible with tokio
ergonomic thread-safe loading before the async runtime starts
Error type contains the variable name
VarError is now flattened to Error variants containing the called variable name
full examples
from_filename deprecated to prevent directory traversal attack
find example added to replicate the old behaviour
More docs and tests have to be added. Feedback is welcome.
This is a breaking fast-forward PR.
std::env::set_var
is marked unsafe in the Rust 2024 edition.set_var
is used in majority of functions in v0.15.This PR introduces a non-modifying API for loading of environment variables. Modifying of the environment is also supported with improved ergonomics limiting the use of
unsafe
.EnvLoader
with_path
andwith_reader
entry points with deferred IOEnvSequence
load
load_and_modify
EnvMap
is aHashMap
newtype withEnvMap::var
load
attribute macroError
type contains the variable nameVarError
is now flattened toError
variants containing the called variable namefrom_filename
deprecated to prevent directory traversal attackfind
example added to replicate the old behaviourMore docs and tests have to be added. Feedback is welcome.
Further reading:
set_var
docsstd::env::VarError::NotPresent
Resolves #14, resolves #25, resolves #39, resolves #68, resolves #105, resolves #106, resolves #48 Progresses #112