Skip to main content

check_yaml_budget

Function check_yaml_budget 

Source
pub fn check_yaml_budget(
    input: &str,
    budget: Budget,
    scope: EnforcingPolicy,
) -> Result<BudgetReport, ScanError>
Expand description

Check an input &str against the given Budget.

Parameters:

  • input: YAML text (UTF-8). If you accept non-UTF-8, transcode before calling.
  • budget: limits to enforce (see Budget).

Returns:

  • Ok(report) — report.breached.is_none() means within budget. If report.breached.is_some(), you should reject the input.
  • Err(ScanError) — scanning (lexing/parsing) failed.

Note:

  • This is streaming and does not allocate a DOM.
  • Depth counts nested SequenceStart and MappingStart.
  • Standalone budget checks do not receive Options; merge keys are counted as if merge expansion is enabled, preserving historical behavior.