env
Dotenv (.env) helpers working on plain text: no file or process-environment access, so
they are deterministic and easy to test. Read the file yourself, edit the content here, and
write it back.
Install
Section titled “Install”Cargo feature env (enabled by default). To compile only this module:
or in Cargo.toml:
Import path: helpers4::env.
| Item | What it does |
|---|---|
get | Returns the value of key in dotenv content, or None when it is not assigned. |
get_bool | Returns key in dotenv content parsed as a boolean, or default when it is absent or not recognized. |
get_duration | Returns key in dotenv content parsed as a human-written duration ("1h30m", "2d", "500ms"), or default when it is absent or does not parse. |
get_int | Returns key in dotenv content parsed as an integer, or default when it is absent or not a valid i64 (a decimal integer, optionally signed; no underscores, no 0x/0b prefixes). |
get_list | Returns key in dotenv content split on separator into a list, or default when it is absent. |
parse | Parses dotenv content into (key, value) pairs, in file order. |
remove | Removes every assignment of key from dotenv content and returns the new content. |
set | Sets key to value in dotenv content and returns the new content. |
Error types
Section titled “Error types”Documented on the page of the helper that returns them.
| Type | Returned by |
|---|---|
InvalidKeyError | set |
