pub struct Commented {
pub comments: Comments,
pub node: CommentedNode,
}Expand description
A Value enriched with per-node comments - what conversion carries so a
commented source survives -T into a commented target.
Fields§
§comments: Comments§node: CommentedNodeImplementations§
Source§impl Commented
impl Commented
Sourcepub fn from_value(value: &Value) -> Commented
pub fn from_value(value: &Value) -> Commented
Wrap a plain value with no comments anywhere.
Sourcepub fn scalar(value: Value) -> Commented
pub fn scalar(value: Value) -> Commented
A scalar node with no comments (convenience for extractors).
Sourcepub fn has_comments(&self) -> bool
pub fn has_comments(&self) -> bool
Does this node or any descendant carry a comment?
Sourcepub fn attach_trailing_foot(&mut self, lines: Vec<String>)
pub fn attach_trailing_foot(&mut self, lines: Vec<String>)
Attach trailing document comments as the foot of the deepest last entry
- the node they physically follow, so re-emission keeps them at the end.
Sourcepub fn descend(&self, path: &[Step]) -> Vec<&Commented>
pub fn descend(&self, path: &[Step]) -> Vec<&Commented>
The nodes a pure path selects, in document order - mirroring the
evaluator’s path semantics (a missing field/index yields nothing;
[] iterates elements/values), so the results align 1:1 with
crate::eval on the same path. A step that cannot apply (e.g. a field
of a scalar) yields nothing here; the evaluator errors first in that
case, so the mismatch is never observed.
Sourcepub fn resolve_comment(&self, path: &[Step]) -> Vec<Value>
pub fn resolve_comment(&self, path: &[Step]) -> Vec<Value>
Resolve a comment-addressing path (a value prefix ending in a terminal
Step::Comment) to the comment text of each selected node, as a
stream of Value::Str. A node without that comment kind contributes
nothing - a miss, matching the rest of the language. The Comment step
is terminal by construction (the parser forbids steps after it).
Sourcepub fn comment_targets(&self) -> Vec<(Vec<Step>, CommentKind, String)>
pub fn comment_targets(&self) -> Vec<(Vec<Step>, CommentKind, String)>
Every comment in the tree as (path steps, kind, text), in document
order - the backbone of the document-wide comments stream (query) and
bulk comment edits (comments |= ...). The steps address the node; the
kind and text are the comment. Paths stay valid across edits (they are
logical, not byte offsets), so a caller may snapshot then apply.