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.
Sharing this format with the duration module’s own parse does not need that module
enabled: env stands alone, like every module here.
Import
Section titled “Import”Cargo feature env (enabled by default). To compile only this module:
or in Cargo.toml:
Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
content | &str | The dotenv text to read. |
key | &str | The variable name to look up. |
default | Duration | Returned when key is absent or its value does not parse. |
Returns
Section titled “Returns”Duration — The parsed duration, or default.
