Skip to main content

parse_duration

Function parse_duration 

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

Parses the &str argument as a Duration Returns Ok(Duration) if successful, or Err(String).

Format is defined as follows: <integer> <unit>

  • whitespace between the integer and unit is optional
  • integer must be positive (>= 0)
  • unit can be one of:
    • ms / millis / millisecond / milliseconds
    • s / sec / secs / second / seconds
    • m / min / mins / minute / minutes
    • h / hour / hours
    • d / day / days