| Crates.io | dotenv_lib |
| lib.rs | dotenv_lib |
| version | 0.6.0 |
| created_at | 2025-07-04 14:00:19.773578+00 |
| updated_at | 2025-07-22 18:15:58.21822+00 |
| description | A dotenv file parser |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1738041 |
| size | 46,506 |
This is a library for parsing dotenv files. It was built for educational purposes and although tested, has not been tested against a baseline .env set of tests.
Example of usage:
use std::fs;
use std::collections::HashMap;
use dotenv_lib as dot;
fn main() {
let contents = fs::read_to_string(".env").expect("unable to read file");
let new_env_map: HashMap<String, String> =
dot::process_dot_env(contents).expect("unable to parse env file");
for (k, v) in new_env_map.iter() {
println!("{} : {}", k, v);
}
}
It is designed to follow the syntax outlined here, but does not perform any interpolation for single-quoted values and does not support triple-quoted values (aka, KEY="""VALUE""").
In brief:
#), newline (\n), and end-of-file.#, =, \n, ', and "), they must be single or double quoted (single to hold double quotes, double to hold single quotes).Please feel free, though, to use it and report any bugs or issues.
key="""example \n value"""). It also does not handle any interpolation