pub struct Document<Loc = Span> {
pub root: Node<Loc>,
pub version: Option<(u8, u8)>,
pub tags: Vec<(String, String)>,
pub comments: Vec<String>,
pub explicit_start: bool,
pub explicit_end: bool,
/* private fields */
}Expand description
A YAML document: a root node plus directive metadata.
Fields§
§root: Node<Loc>The root node of the document.
version: Option<(u8, u8)>YAML version declared by a %YAML directive, if present (e.g. (1, 2)).
Tag handle/prefix pairs declared by %TAG directives (handle, prefix).
comments: Vec<String>Comments that appear at document level (before or between nodes).
explicit_start: boolWhether the document was introduced with an explicit --- marker.
explicit_end: boolWhether the document was closed with an explicit ... marker.
Implementations§
Source§impl<Loc> Document<Loc>
impl<Loc> Document<Loc>
Sourcepub const fn with_root(root: Node<Loc>) -> Self
pub const fn with_root(root: Node<Loc>) -> Self
Construct a document with the given root node and all metadata set to their default values.
This constructor is intended for unit tests that synthesise AST nodes
without going through the loader. The line_index is set to None;
calling line_index() on the resulting document will panic.
Source§impl Document<Span>
impl Document<Span>
Sourcepub fn line_index(&self) -> &LineIndex
pub fn line_index(&self) -> &LineIndex
Return the LineIndex for this document, used to resolve byte offsets
from Span values to (line, column) pairs.
§Panics
Panics if the document was not created by the loader (i.e., line_index
is None). All documents returned by load() or Loader::load() have a
LineIndex set.