Expand description
Very simple helper functions for environment variables and environment variable-driven
env_logger
configuration.
Enums§
- EnvError
- Errors with env variables.
Constants§
- ENV_
RUST_ LOG - Name of the environment variable Rust’s env logger uses
Functions§
- get_
env_ bool_ optional - Get an environment variable as a bool.
If not present or there is an error in parsing, return
None
. - get_
env_ bool_ or_ default - Get an environment variable as a bool, or fall back to the provided default. Returns the default in the event of a parse error.
- get_
env_ bool_ required - Get an environment variable as a bool. If not provided or cannot parse, return an error.
- get_
env_ duration_ seconds_ optional - Get an environment variable as a
Duration
in seconds. If not present or there is an error in parsing, returnNone
. - get_
env_ duration_ seconds_ or_ default - Get an environment variable as a
Duration
in seconds, or fall back to the provided default. Returns the default in the event of a parse error. - get_
env_ duration_ seconds_ required - Get an environment variable as a
Duration
in seconds. If not provided or cannot parse, return an error. - get_
env_ num - Get an environment variable as a number, or fall back to the provided default if not set. If the env var is present but can’t be parsed, an error is returned instead.
- get_
env_ pathbuf_ optional - Get an environment variable as a
PathBuf
. If not present or there is an error in parsing, returnNone
. - get_
env_ pathbuf_ or_ default - Get an environment variable as a
PathBuf
, or fall back to the provided default. Returns the default in the event of a parse error. - get_
env_ pathbuf_ required - Get an environment variable as a
PathBuf
. If not provided or cannot parse, return an error. - get_
env_ string_ optional - Get an environment variable as an optional
String
. - get_
env_ string_ or_ default - Get an environment variable as a
String
, or fall back to the provided default. - get_
env_ string_ required - Get an environment variable as a
String
, or return an error. - init_
all_ with_ default_ logging - Initialize dotenv and env logger.
See
init_dotenv()
andinit_env_logger(Option<&str>)
for further details. - init_
dotenv - Initialize dotenv with the default
.env
config file. - init_
env_ logger - Initialize Rust’s env logger.