Module ilyvion_util::environment
source · Available on crate feature
environment
only.Expand description
Provides a macro to help with using environment variables more ergonomically.
Macros
- define_environment
better-docs
This macro declares utility functions for reading the given environment variables. For a given environment variable, two functions are generated, one that is named the same as the declared environment variable which panics if the environment variable isn’t present and one prefixed withtry_
that returns aResult
(see the return value ofstd::env::var
for details on the error.) If a: $type
is added to the definition, two additional functions get added: one with the suffix_$type
and one with the prefixtry_
and the suffix_$type
. These functions behave the same as the two regular functions, but they invokeEnvironmentConverter::try_convert
to attempt to convert the text in the environment variable to the given type. The one prefixed withtry_
passes the eventual conversion error on in aEnvironmentConverterError
, the unprefixed one panics instead.
Structs
- The error type for converting to
bool
.
Enums
- The error type used in
EnvironmentConverter
implementations
Traits
- The trait responsible for converting environment variable contents into other types.