EnvMan: Environments (variables) Manager
EnvMan is a Rust crate that provides a procedural macro to simplify the management of environment variables. It allows you to automatically load and parse environment variables into your Rust structs, with support for default values, custom parsers, and more.
Features
- Automatic Environment Variable Loading: Automatically load environment variables into struct fields.
- Customizable Field Attributes: Use attributes to customize field names, parsers, default values, and more.
- Support for Nested Structs: Easily manage nested configurations with support for nested structs.
- Flexible Naming Conventions: Use
rename_all,prefix, andsuffixto control environment variable naming.
Usage
Here's a basic example demonstrating how to use EnvMan to manage environment variables:
use EnvMan;
use IpAddr;
Attributes
Struct Attributes
rename_all: Apply a naming convention to all fields (default:SCREAMING_SNAKE_CASE).prefix: Add a prefix to all field names.suffix: Add a suffix to all field names.
Field Attributes
rename: Specify a custom environment variable name for a field.default: Provide a default value if the environment variable is not set.parser: Use a custom parser function to parse the environment variable. (default:FromStr::from_str)nest: Indicate that the field is a nested struct implementingEnvMan.alltime_parse: Always use the specified parser to parse the environment variable, even if a default value is provided.
More Info
more info: doc.rs
License
Licensed under