Ground Env
ground-env is a Rust crate that provides a convenient way to load environment variables into your structs. It uses custom derive macros to automatically map environment variables to struct fields, with support for various features such as renaming fields, default values, flattening nested structures, and handling different delimiters.
Features
- Simple Mapping: Map environment variables directly to struct fields.
- Optional Fields: Handle optional environment variables seamlessly.
- Renaming: Rename struct field names to match the desired environment variables.
- Default Values: Define default values for fields if the environment variable is missing.
- Flattening: Flatten nested structures.
- Vectors: Parse environment variables into vectors with custom delimiters.
- Error Handling: Graceful handling of missing required fields and invalid data types.
Usage
Add ground-env to your Cargo.toml:
[]
= "0.1.0"
Annotate your structs with the #[derive(FromEnv)] macro and configure the mapping using attributes:
License
This project is licensed under the MIT License. See the LICENSE file for details.