pub fn parse_contract_str(yaml: &str) -> Result<Contract, ContractError>Expand description
Parse a YAML contract from a string.
Two passes on purpose. Contract is intentionally NOT
#[serde(deny_unknown_fields)] — 1224 of the 1726 contracts pv lint
walks carry a downstream-owned top-level block (family:, sections:,
surface:, …) and denying them would stop ~71% of the corpus from parsing
in one commit. But serde’s tolerance is also what let a top-level kind:
(119 contracts) and a misspelled falsification: block vanish without a
sound. So the second pass reads the raw mapping and records which top-level
keys serde did not consume, in Contract::unknown_top_level_keys; the
validator turns the never-legitimate ones into errors (SCHEMA-018 /
SCHEMA-019) and leaves the rest alone.
§Errors
Returns ContractError::Yaml if the YAML is malformed or does not match
the contract schema.