Function marked_yaml::parse_yaml

source ·
pub fn parse_yaml<S>(source: usize, yaml: S) -> Result<Node, LoadError>
where S: AsRef<str>,
Expand description

Parse YAML from a string and return a Node representing the content.

When parsing YAML, the source is stored into all markers which are in the node spans. This means that later if you only have a node, you can determine which source it came from without needing complex lifetimes to bind strings or other non-copy data to nodes.

This library requires that the top level be a mapping, but the returned type here is the generic Node enumeration to make it potentially easier for callers to use. Regardless, it’s always possible to treat the returned node as a mapping node without risk of panic.

let node = parse_yaml(0, include_str!("../examples/everything.yaml"))
    .unwrap()
    .as_mapping()
    .unwrap();