Skip to main content

parse

Function parse 

Source
pub fn parse(yaml: &str) -> Result<ScenarioFile, ParseError>
Expand description

Parse a YAML string as a v2 scenario file.

Performs deserialization followed by structural validation:

  1. Version must be exactly 2.
  2. Single-signal shorthand (no scenarios: key) is promoted to a one-entry file.
  3. Entry id values must be unique and match [a-zA-Z_][a-zA-Z0-9_]*.
  4. signal_type must be one of metrics, logs, histogram, summary.
  5. Each entry has either generator/distribution or pack, not both.
  6. Cross-generator mutual exclusion: each signal type may only carry its expected generator field (generator for metrics, log_generator for logs, distribution for histogram/summary). The other fields must be absent.
  7. Pack entries must have signal_type: metrics.
  8. Inline (non-pack) entries must have name.

Note: after.ref references are not resolved during parsing. Reference resolution, threshold validation, and timing computation happen during compilation (see the after compiler).

Note: after.op is deserialized as an AfterOp enum. Invalid operator values (anything other than "<" or ">") are rejected by serde during deserialization.

§Errors

Returns ParseError describing the first validation failure found.