parse_duration_or_nanos

Function parse_duration_or_nanos 

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

Parses a duration string the way the Datadog Agent does: first as a strict Go duration via parse_duration, then as a bare integer count of nanoseconds when the trimmed input contains only an integer. For example, "30" becomes 30 nanoseconds. Surrounding whitespace is ignored.

Use parse_duration instead when only Go’s time.ParseDuration grammar should be accepted.

§Errors

Returns ParseDurationError when the value is neither a Go duration nor a bare integer, is negative, or exceeds the supported nanosecond range.