Skip to main content

Crate dotenv

Crate dotenv 

Source
Expand description

§dotenvs

crates.io Released API docs MIT licensed

A correct dotenv library with variable substitution.

  • Variable substitution: $VAR, ${VAR}, ${VAR:-default}
  • Three quote styles (`’ “ ``), multi-line values
  • Overwrite or preserve existing environment variables
  • export prefix for shell compatibility

§Usage

Note:

The crate is named dotenvs, but its lib is dotenv.

[dependencies]
dotenvs = "0.2"
dotenv::load();

// iterate all variables
for (key, value) in dotenv::vars() {
    println!("{}: {}", key, value);
}

§License

MIT

Structs§

Dotenv
Parsed dotenv content

Enums§

Error
Errors that can occur when working with dotenv files.

Functions§

from_filename
Create Dotenv from the specified file.
from_path
Create Dotenv from the specified path.
from_read
Create Dotenv from any Read implementor.
load
Load the .env file 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.

Type Aliases§

Result