pub enum Event<'input> {
StreamStart,
StreamEnd,
Comment {
text: &'input str,
},
Alias {
name: &'input str,
},
DocumentStart {
explicit: bool,
version: Option<(u8, u8)>,
tag_directives: Vec<(String, String)>,
},
DocumentEnd {
explicit: bool,
},
SequenceStart {
anchor: Option<&'input str>,
tag: Option<Cow<'input, str>>,
style: CollectionStyle,
},
SequenceEnd,
MappingStart {
anchor: Option<&'input str>,
tag: Option<Cow<'input, str>>,
style: CollectionStyle,
},
MappingEnd,
Scalar {
value: Cow<'input, str>,
style: ScalarStyle,
anchor: Option<&'input str>,
tag: Option<Cow<'input, str>>,
},
}Expand description
A high-level YAML parse event.
Variants§
StreamStart
The YAML stream has started.
Always the first event in any parse. The associated span is a
zero-width span at crate::pos::Pos::ORIGIN.
StreamEnd
The YAML stream has ended.
Always the last event in any parse. The associated span is a zero-width span at the position immediately after the last byte of input.
Comment
A YAML comment (YAML 1.2 §6.6).
text is the comment body — the content of the line after the #
character, with the # itself excluded. Leading whitespace after #
is preserved (e.g. # hello → text " hello"; #nospace → text
"nospace"). The associated span covers from the # character
through the last byte of comment text (the newline is not included).
One Comment event is emitted per physical line.
Alias
An alias node (*name) that references a previously anchored node.
The associated span covers the entire *name token (from * through
the last character of the name). Resolution of the alias to its
anchored node is the loader’s responsibility (Task 20) — the parser
emits this event without expansion.
Fields
DocumentStart
A document has started.
explicit is true when the document was introduced with ---.
false for bare documents (no marker).
Fields
DocumentEnd
A document has ended.
explicit is true when the document was closed with ....
false for implicitly-ended documents.
SequenceStart
A block or flow sequence has started.
Followed by zero or more node events (scalars or nested collections),
then a matching Event::SequenceEnd.
Fields
tag: Option<Cow<'input, str>>The resolved tag, if any (e.g. "tag:yaml.org,2002:seq" for !!seq).
Verbatim tags (!<URI>) borrow from input. Shorthand tags resolved
via %TAG directives or the built-in !! default produce owned strings.
style: CollectionStyleWhether this is a block (- indicator) or flow ([...]) sequence.
SequenceEnd
A sequence has ended.
Matches the most recent Event::SequenceStart on the event stack.
MappingStart
A block or flow mapping has started.
Followed by alternating key/value node events (scalars or nested
collections), then a matching Event::MappingEnd.
Fields
tag: Option<Cow<'input, str>>The resolved tag, if any (e.g. "tag:yaml.org,2002:map" for !!map).
See [SequenceStart::tag] for resolution semantics.
style: CollectionStyleWhether this is a block (indentation-based) or flow ({...}) mapping.
MappingEnd
A mapping has ended.
Matches the most recent Event::MappingStart on the event stack.
Scalar
A scalar value.
value borrows from input when no transformation is required (the
vast majority of plain scalars). It owns when line folding produces
a string that doesn’t exist contiguously in the input.
Fields
style: ScalarStyleThe style in which the scalar appeared in the source.