#[non_exhaustive]pub enum Event<'input> {
StreamStart,
StreamEnd,
DocumentStart(bool, Option<YamlVersion>),
DocumentEnd,
Alias(usize),
Comment(Cow<'input, str>, Placement),
Scalar(Cow<'input, str>, ScalarStyle, usize, Option<Cow<'input, Tag>>),
SequenceStart(StructureStyle, usize, Option<Cow<'input, Tag>>),
SequenceEnd,
MappingStart(StructureStyle, usize, Option<Cow<'input, Tag>>),
MappingEnd,
}Expand description
An event generated by the YAML parser.
Events are used in the low-level event-based API (push parser). The API entrypoint is the
EventReceiver trait.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
StreamStart
Event generated at the very beginning of parsing.
StreamEnd
Last event that will be generated by the parser. Signals EOF.
DocumentStart(bool, Option<YamlVersion>)
The start of a YAML document.
Tuple Fields
0: boolWhether this is an explicit document start marker (---).
When false, the document start is implicit.
1: Option<YamlVersion>YAML version declared by a preceding %YAML directive, if any.
DocumentEnd
The end of a YAML document.
This event is emitted for both explicit document end markers (...) and implicit document
ends.
Alias(usize)
A YAML alias.
Comment(Cow<'input, str>, Placement)
A YAML source comment.
Comments are presentation metadata, not YAML data nodes. The payload is the raw text
exactly after #, excluding only the line break. The placement is a best-effort hint for
correlating the comment with nearby YAML presentation. The companion parser Span covers
the whole source comment, including # and excluding the line break.
Tuple Fields
Scalar(Cow<'input, str>, ScalarStyle, usize, Option<Cow<'input, Tag>>)
A YAML scalar value.
Tuple Fields
1: ScalarStyleThe source notation used for the scalar.
SequenceStart(StructureStyle, usize, Option<Cow<'input, Tag>>)
The start of a YAML sequence (array).
Tuple Fields
0: StructureStyleThe notation style used for the sequence.
SequenceEnd
The end of a YAML sequence (array).
MappingStart(StructureStyle, usize, Option<Cow<'input, Tag>>)
The start of a YAML mapping (object, hash).
Tuple Fields
0: StructureStyleThe notation style used for the mapping (Flow or Block).
MappingEnd
The end of a YAML mapping (object, hash).
Implementations§
Source§impl<'input> Event<'input>
impl<'input> Event<'input>
Sourcepub fn anchor_id(&self) -> Option<usize>
pub fn anchor_id(&self) -> Option<usize>
Return the anchor ID defined by this event, if any.
Returns Some(id) when this event defines an anchor on a scalar, sequence, or mapping
node. Returns None for all other events, including Alias (which references an anchor
rather than defining one; use Self::alias_id to obtain the target anchor ID).
Sourcepub fn alias_id(&self) -> Option<usize>
pub fn alias_id(&self) -> Option<usize>
Return the target anchor ID referenced by this alias event, if this event is an alias.
Sourcepub fn scalar(&self) -> Option<(&str, ScalarStyle)>
pub fn scalar(&self) -> Option<(&str, ScalarStyle)>
Return the scalar value and style, if this event is a scalar.