Skip to main content

parse_duration

Function parse_duration 

Source
pub fn parse_duration(s: &str) -> Result<Duration, String>
Expand description

Parse a human-readable duration like 250ms, 30s, 5m, 2h, or 7d into a chrono::Duration.

A unit suffix is required; a bare integer is an error (see the module docs for why, and which caller compensates). The error is a plain String so both the String-erroring config layer and the CliError-erroring CLI layer can wrap it without a shared error type.