MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / parse_duration

Method parse_duration

nodedb/src/control/promql/parser.rs:297–308  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

295 }
296
297 fn parse_duration(&mut self) -> Result<Duration, PromqlError> {
298 match self.advance().clone() {
299 Token::Duration(s) => {
300 Duration::parse(&s).ok_or(PromqlError::InvalidDuration { literal: s })
301 }
302 Token::Number(n) if n > 0.0 => Ok(Duration((n * 1000.0) as i64)),
303 t => Err(PromqlError::UnexpectedToken {
304 expected: "duration".to_string(),
305 found: format!("{t:?}"),
306 }),
307 }
308 }
309
310 fn try_parse_grouping(&mut self) -> Result<Grouping, PromqlError> {
311 if self.try_keyword("by") {

Callers 1

parse_postfixMethod · 0.80

Calls 5

DurationClass · 0.85
to_stringMethod · 0.80
parseFunction · 0.70
cloneMethod · 0.45
advanceMethod · 0.45

Tested by

no test coverage detected