Skip to main content

parse_step

Function parse_step 

Source
pub fn parse_step(input: &str) -> Result<u64, ObzError>
Expand description

Parse a query step string (e.g., 15s, 1m, 5m) into seconds.

Supports Prometheus-style duration suffixes and bare numbers (seconds).

§Errors

Returns ObzError::InvalidArgument if the input is invalid.

§Examples

use obz_core::time::parse_step;

assert_eq!(parse_step("15s").unwrap(), 15);
assert_eq!(parse_step("1m").unwrap(), 60);
assert_eq!(parse_step("5m").unwrap(), 300);
assert_eq!(parse_step("1h").unwrap(), 3600);
assert_eq!(parse_step("30").unwrap(), 30);