pub struct Cursor<'a> {
pub path: String,
/* private fields */
}Expand description
A read-only cursor into a Doc’s tree, tracking its own path.
Path is owned per-cursor (rather than borrowed) because it’s built
incrementally ($.a.b[1]) as cursors descend; it’s only needed for
error messages and equality with Python’s Doc.path, not perf-critical
traversal.
Fields§
§path: StringThe path of this cursor within the document.
Implementations§
Source§impl<'a> Cursor<'a>
impl<'a> Cursor<'a>
Sourcepub fn value(&self) -> Result<&'a Scalar, DocumentError>
pub fn value(&self) -> Result<&'a Scalar, DocumentError>
Returns the scalar value if this is a leaf node, or Err if it is an internal edge node.
Sourcepub fn edges(&self) -> Result<Vec<(String, Cursor<'a>)>, DocumentError>
pub fn edges(&self) -> Result<Vec<(String, Cursor<'a>)>, DocumentError>
Returns the outgoing labeled edges if this is an internal node, or Err if it is a leaf.
Sourcepub fn get(&self, label: &str) -> Vec<Cursor<'a>>
pub fn get(&self, label: &str) -> Vec<Cursor<'a>>
Returns all child cursors along edges with the given label.
Sourcepub fn get_one(&self, label: &str) -> Result<Cursor<'a>, DocumentError>
pub fn get_one(&self, label: &str) -> Result<Cursor<'a>, DocumentError>
Returns the single child cursor for label, or Err if there are 0 or >1 matching edges.
Sourcepub fn child(&self, label: &str) -> Result<Cursor<'a>, DocumentError>
pub fn child(&self, label: &str) -> Result<Cursor<'a>, DocumentError>
A cursor to the single child under label.
Sourcepub fn to_raw(&self) -> RawNode
pub fn to_raw(&self) -> RawNode
A lossless RawNode copy of the subtree rooted at this cursor,
preserving edge order and interleaving exactly. Used by
crate::materialize to carry an untouched subtree forward (e.g. an
unexpected field it still has to emit for a caller inspecting the
materialized-but-erroring result) without a second, hand-rolled
tree-copy routine.