pub enum Node<Loc = Span> {
Scalar {
value: String,
style: ScalarStyle,
anchor: Option<String>,
anchor_loc: Option<Loc>,
tag: Option<String>,
tag_loc: Option<Loc>,
loc: Loc,
leading_comments: Option<Vec<String>>,
trailing_comment: Option<String>,
},
Mapping {
entries: Vec<(Self, Self)>,
style: CollectionStyle,
anchor: Option<String>,
anchor_loc: Option<Loc>,
tag: Option<String>,
tag_loc: Option<Loc>,
loc: Loc,
leading_comments: Option<Vec<String>>,
trailing_comment: Option<String>,
},
Sequence {
items: Vec<Self>,
style: CollectionStyle,
anchor: Option<String>,
anchor_loc: Option<Loc>,
tag: Option<String>,
tag_loc: Option<Loc>,
loc: Loc,
leading_comments: Option<Vec<String>>,
trailing_comment: Option<String>,
},
Alias {
name: String,
loc: Loc,
leading_comments: Option<Vec<String>>,
trailing_comment: Option<String>,
},
}Expand description
A YAML node parameterized by its location type.
Variants§
Scalar
A scalar value.
Fields
style: ScalarStyleThe presentation style used in the source (plain, single-quoted, etc.).
anchor_loc: Option<Loc>Source span of the &name anchor token — from & through the last byte of the
name. Some when anchor is Some; None otherwise.
tag_loc: Option<Loc>Source span of the tag token — from ! through the last byte of the tag.
Some when tag is Some; None otherwise.
loc: LocSource span covering this scalar in the input.
Mapping
A mapping (sequence of key–value pairs preserving declaration order).
Fields
style: CollectionStyleThe presentation style used in the source (block or flow).
anchor_loc: Option<Loc>Source span of the &name anchor token — from & through the last byte of the
name. Some when anchor is Some; None otherwise.
tag_loc: Option<Loc>Source span of the tag token — from ! through the last byte of the tag.
Some when tag is Some; None otherwise.
loc: LocSource span from the opening indicator to the last entry.
Sequence
A sequence (ordered list of nodes).
Fields
style: CollectionStyleThe presentation style used in the source (block or flow).
anchor_loc: Option<Loc>Source span of the &name anchor token — from & through the last byte of the
name. Some when anchor is Some; None otherwise.
tag_loc: Option<Loc>Source span of the tag token — from ! through the last byte of the tag.
Some when tag is Some; None otherwise.
loc: LocSource span from the opening indicator to the last item.
Alias
An alias reference (lossless mode only — resolved mode expands these).
Implementations§
Source§impl<Loc> Node<Loc>
impl<Loc> Node<Loc>
Sourcepub const fn anchor_loc(&self) -> Option<Loc>where
Loc: Copy,
pub const fn anchor_loc(&self) -> Option<Loc>where
Loc: Copy,
Returns the source span of the &name anchor token, if any.
Some(span) when anchor() is Some; None otherwise.
Always None for Node::Alias — the alias span is in loc.
Sourcepub const fn tag_loc(&self) -> Option<Loc>where
Loc: Copy,
pub const fn tag_loc(&self) -> Option<Loc>where
Loc: Copy,
Returns the source span of the tag token, if any.
Some(span) when tag() is Some; None otherwise.
Always None for Node::Alias.
Sourcepub fn leading_comments(&self) -> &[String]
pub fn leading_comments(&self) -> &[String]
Returns the leading comments for this node.
Sourcepub fn trailing_comment(&self) -> Option<&str>
pub fn trailing_comment(&self) -> Option<&str>
Returns the trailing comment for this node, if any.