A Rust library for modifying structs via environment variables.
Unlike envy, this does not create a new object. It is used to reconfigure an existing structure (after having parsed it from a config file, for example).
Ignored fields
If a certain field should not be configurable via environment variables, mark it with #[env(ignore)]
.
Examples
Creating a config structure:
use FromEnv;
// Creates a base configuration struct to add on to.
// Normally this would be created using `serde` from a config file.
let mut config = default;
// Names the struct "MY_CONFIG", which acts as a prefix.
config.with_env.unwrap;
Nesting fields:
use FromEnv;
Generates:
- MY_CONFIG_SERVER_PORT
Vector of Nested fields:
use FromEnv;
// `Vec`'s `FromEnv` implementation requires `Default`.
Generates:
- MY_CONFIG_SERVER_0_PORT