Available on crate feature environment only.
Expand description

Provides a macro to help with using environment variables more ergonomically.

Macros

  • 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 with try_ that returns a Result (see the return value of std::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 prefix try_ and the suffix _$type. These functions behave the same as the two regular functions, but they invoke EnvironmentConverter::try_convert to attempt to convert the text in the environment variable to the given type. The one prefixed with try_ passes the eventual conversion error on in a EnvironmentConverterError, the unprefixed one panics instead.

Structs

Enums

Traits

  • The trait responsible for converting environment variable contents into other types.