Expand description
§DotenvPP
From-scratch .env parsing, interpolation, and layered loading for Rust.
§Quick Start
dotenvpp::load().ok();
let db_url = dotenvpp::var("DATABASE_URL").unwrap();§API Overview
| Function | Description |
|---|---|
load() | Load layered .env files from cwd without overriding existing vars |
load_override() | Load layered .env files overriding existing vars |
load_with_env() | Load layered files for a named environment |
from_layered_env() | Preview layered config without mutating the process env |
from_path() | Load and resolve a specific file |
from_read() | Parse and resolve from any impl Read |
var() | Get a single env var |
vars() | Iterate all env vars |
vars_os() | Iterate env vars without Unicode conversion |
Structs§
- EnvPair
- A parsed key-value pair from a
.envfile. - Interpolation
Error - Interpolation failures for
${VAR}style expansions.
Enums§
- Error
- Errors that can occur when loading
.envfiles. - Interpolation
Error Kind - Specific interpolation failure kinds.
- Parse
Error - Errors that can occur while parsing
.envcontent.
Functions§
- from_
layered_ env - Resolve layered
.envfiles from the current directory without mutating the process environment. - from_
path - Load environment variables from a specific file path.
- from_
path_ iter - Resolve a
.envfile and return an iterator over the final key/value pairs without setting them in the environment. - from_
path_ override - Load environment variables from a specific file path and override existing process variables.
- from_
read - Parse
.envcontent from any reader without setting env vars. - load
- Load layered environment files from the current directory.
- load_
override - Load layered environment files from the current directory and override existing process variables.
- load_
with_ env - Load layered environment files for a specific environment name.
- load_
with_ env_ override - Load layered environment files for a specific environment name and override existing process variables.
- var
- Get a single environment variable’s value.
- vars
- Returns an iterator over all environment variables as
(String, String)pairs. - vars_os
- Returns an iterator over all environment variables as
(OsString, OsString)pairs. - version
- Returns the crate version.
Type Aliases§
- Result
- Convenience type alias.