Skip to main content

parse_duration

Function parse_duration 

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

Parse a CEL duration("…") string into a chrono::Duration.

Accepts the protobuf duration grammar: an optional sign, a decimal number, and one of the suffixes ns / us / µs / ms / s / m / h. Returns None on any parse error so the caller can decide whether to map that to a CEL runtime error.

Used by codegen for duration(this.field) where this.field isn’t a compile-time-known string literal; literal-arg paths fold the parse into duration_from_secs_nanos(secs, nanos) at codegen time and do not call this.