Expand description
Load and use environment variables from .env files.
§Overview
This crate parses .env files with variable substitution support:
$VAR, ${VAR}, ${VAR:-default}. It provides both convenience
functions (for typical usage) and a builder-style Dotenv type
(for fine-grained control).
§Quick start
dotenv::load().ok();
for (key, value) in dotenv::vars() {
println!("{key}={value}");
}§Available entry points
| Task | Function / Type |
|---|---|
Load .env automatically | load(), var(), vars() |
| Load a specific file | from_path(), from_filename() |
| Load from a custom source | from_read() |
| Builder with control over behaviour | Dotenv |
Structs§
- Dotenv
- Parsed dotenv content
Enums§
- Error
- Errors that can occur when working with dotenv files.
Functions§
- from_
filename - Create
Dotenvfrom the specified file. - from_
path - Create
Dotenvfrom the specified path. - from_
read - Create
Dotenvfrom anyReadimplementor. - load
- Load the
.envfile from the current directory or its parents. - var
- Get the value for an environment variable.
- vars
- Return an iterator of
(key, value)pairs for all environment variables of the current process.