pub enum Node<Loc = Span> {
Scalar {
value: String,
style: ScalarStyle,
tag: Option<Cow<'static, str>>,
loc: Loc,
meta: Option<Box<NodeMeta<Loc>>>,
},
Mapping {
entries: Vec<(Self, Self)>,
style: CollectionStyle,
tag: Option<Cow<'static, str>>,
loc: Loc,
meta: Option<Box<NodeMeta<Loc>>>,
},
Sequence {
items: Vec<Self>,
style: CollectionStyle,
tag: Option<Cow<'static, str>>,
loc: Loc,
meta: Option<Box<NodeMeta<Loc>>>,
},
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.).
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).
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).
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 fn anchor_loc(&self) -> Option<Loc>where
Loc: Copy,
pub 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 fn tag_loc(&self) -> Option<Loc>where
Loc: Copy,
pub fn tag_loc(&self) -> Option<Loc>where
Loc: Copy,
Returns the source span of the tag token, if any.
Some(span) when a user-authored tag is present; None for resolver-injected tags.
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.
Sourcepub fn clear_anchor(&mut self)
pub fn clear_anchor(&mut self)
Clear the anchor and anchor_loc on this node (used by code actions that
remove unused anchors). No-op on Node::Alias.