Skip to main content

parse_rule

Function parse_rule 

Source
pub fn parse_rule(line: &str, source: &str) -> Result<Rule, ParseError>
Expand description

Parse a single rule line into a Rule.

Accepted forms (DSL §3.2):

  1. "require(...)" → rule-level shorthand, desugars to when: <negated condition> do: deny per DSL §8.1
  2. "<predicate>: <action>" → Rule { condition, action }
  3. "<predicate>" → Rule { condition, action: Deny } (default)
  4. "<action>" (action only) → treated as form 3 (always-true predicate)

Step kinds (plugin(...), taint(...), cedar:, opa(...) etc.) are handled by parse_step, not here. This function specifically parses predicate-and-action rules; callers that don’t know which they have should use parse_step instead.