Skip to main content

read_yaml

Function read_yaml 

Source
pub fn read_yaml(text: &str) -> Result<Doc, OmnistError>
Expand description

Parse YAML text into a Doc, with the default YamlReadOptions.

Exactly one YAML document is accepted (matching Python’s yaml.safe_load, which raises on a stream containing more than one ----separated document); an empty/blank input parses as a Null document, also matching yaml.safe_load("") returning None. A bare top-level sequence, a sequence nested directly inside another sequence, or nesting past crate::document::MAX_DEPTH all surface as crate::error::DocumentError (via Doc::of), matching json.rs’s identical read_json behavior.

Input whose alias expansion factor exceeds DEFAULT_MAX_ALIAS_EXPANSION (spec D-18), or that holds a self-referential anchor (D-20), is rejected with document.limit.alias-expansion at $ before anything is materialized; see read_yaml_with to change the maximum.