Skip to main content

dotenvpp_parser/
lib.rs

1//! # dotenvpp-parser
2//!
3//! Core `.env` file parser for DotenvPP.
4//!
5//! This crate is `no_std`-compatible (with `alloc`) so it can be used
6//! in WASM and embedded environments. Enable the `std` feature (on by
7//! default) for `std::error::Error` implementations.
8//!
9//! ## Features
10//!
11//! - `KEY=VALUE` basic parsing with comment and blank-line handling
12//! - Single-quoted values (literal, multiline supported), double-quoted values
13//!   (with escapes), and unquoted values
14//! - Multiline values in single-quoted and double-quoted strings
15//! - `export KEY=VALUE` prefix support
16//! - Escape sequences: `\\`, `\"`, `\n`, `\t`, `\r`, `\$`
17//! - Common unquoted escapes for spaces, quotes, dollar signs, and newlines
18//!
19//! ## Example
20//!
21//! ```
22//! use dotenvpp_parser::parse;
23//!
24//! let input = "# Database config\nDB_HOST=localhost\nDB_PORT=5432\nSECRET='keep-it-safe'\n";
25//!
26//! let pairs = parse(input).unwrap();
27//! assert_eq!(pairs.len(), 3);
28//! assert_eq!(pairs[0].key, "DB_HOST");
29//! assert_eq!(pairs[0].value, "localhost");
30//! ```
31
32#![cfg_attr(not(feature = "std"), no_std)]
33
34extern crate alloc;
35
36mod error;
37mod parser;
38
39pub use error::ParseError;
40pub use parser::{parse, EnvPair};