pub struct NodeInner { /* private fields */ }Expand description
The inner data of a node in the parse tree.
Each node has:
- 0 or more children
- XML content (element or text)
- A parent (except for root)
- A position among siblings
- An optional match area tag
- Kind-specific data (Base or Branch)
Implementations§
Source§impl NodeInner
impl NodeInner
Sourcepub fn new_base(content: Option<XmlContent>) -> Self
pub fn new_base(content: Option<XmlContent>) -> Self
Creates a new base node with the given content.
Sourcepub fn new_branch(content: Option<XmlContent>) -> Self
pub fn new_branch(content: Option<XmlContent>) -> Self
Creates a new branch node with the given content.
Sourcepub fn content(&self) -> Option<&XmlContent>
pub fn content(&self) -> Option<&XmlContent>
Returns the content of this node.
Sourcepub fn content_mut(&mut self) -> Option<&mut XmlContent>
pub fn content_mut(&mut self) -> Option<&mut XmlContent>
Returns a mutable reference to the content.
Sourcepub fn set_content(&mut self, content: Option<XmlContent>)
pub fn set_content(&mut self, content: Option<XmlContent>)
Sets the content of this node.
Sourcepub fn child_count(&self) -> usize
pub fn child_count(&self) -> usize
Returns the number of children.
Sourcepub fn child(&self, index: usize) -> Option<&NodeRef>
pub fn child(&self, index: usize) -> Option<&NodeRef>
Returns a reference to the child at the given index.
Sourcepub fn child_pos(&self) -> i32
pub fn child_pos(&self) -> i32
Returns the child position (0-based index among siblings, -1 for root).
Sourcepub fn match_area(&self) -> Option<&Rc<MatchArea>>
pub fn match_area(&self) -> Option<&Rc<MatchArea>>
Returns the match area, if set.
Sourcepub fn set_match_area(&mut self, area: Option<Rc<MatchArea>>)
pub fn set_match_area(&mut self, area: Option<Rc<MatchArea>>)
Sets the match area.
Sourcepub fn has_left_sibling(&self) -> bool
pub fn has_left_sibling(&self) -> bool
Returns true if this node has a left sibling.
Sourcepub fn has_right_sibling(&self) -> bool
pub fn has_right_sibling(&self) -> bool
Returns true if this node has a right sibling.
Sourcepub fn match_type(&self) -> Option<MatchType>
pub fn match_type(&self) -> Option<MatchType>
Returns the match type for branch nodes, None for base nodes.
Sourcepub fn get_base_match(&self) -> Option<&Weak<RefCell<NodeInner>>>
pub fn get_base_match(&self) -> Option<&Weak<RefCell<NodeInner>>>
Returns the base match for branch nodes (a weak reference to the matched base node). Returns None for base nodes or if no match has been set.
Sourcepub fn set_base_match(&mut self, base: &NodeRef)
pub fn set_base_match(&mut self, base: &NodeRef)
Sets the base match for a branch node. Does nothing for base nodes.
Sourcepub fn set_match_type(&mut self, mt: MatchType)
pub fn set_match_type(&mut self, mt: MatchType)
Sets the match type for a branch node. Does nothing for base nodes.
Sourcepub fn del_base_match(&mut self)
pub fn del_base_match(&mut self)
Clears the base match for a branch node.
Source§impl NodeInner
Helper functions that work with NodeRef.
impl NodeInner
Helper functions that work with NodeRef.
Sourcepub fn add_child_to_ref(parent_ref: &NodeRef, child_ref: NodeRef)
pub fn add_child_to_ref(parent_ref: &NodeRef, child_ref: NodeRef)
Adds a child node. Must be called on the NodeRef wrapper.
Sourcepub fn add_child_at_to_ref(
parent_ref: &NodeRef,
index: usize,
child_ref: NodeRef,
)
pub fn add_child_at_to_ref( parent_ref: &NodeRef, index: usize, child_ref: NodeRef, )
Inserts a child at the given index.
Sourcepub fn replace_child_to_ref(
parent_ref: &NodeRef,
index: usize,
child_ref: NodeRef,
)
pub fn replace_child_to_ref( parent_ref: &NodeRef, index: usize, child_ref: NodeRef, )
Replaces a child at the given index.
Sourcepub fn remove_child_to_ref(parent_ref: &NodeRef, index: usize)
pub fn remove_child_to_ref(parent_ref: &NodeRef, index: usize)
Removes the child at the given index.
Sourcepub fn remove_children_to_ref(parent_ref: &NodeRef)
pub fn remove_children_to_ref(parent_ref: &NodeRef)
Removes all children.
Sourcepub fn left_sibling_of_ref(node_ref: &NodeRef) -> Option<NodeRef>
pub fn left_sibling_of_ref(node_ref: &NodeRef) -> Option<NodeRef>
Gets the left sibling of a node.
Sourcepub fn right_sibling_of_ref(node_ref: &NodeRef) -> Option<NodeRef>
pub fn right_sibling_of_ref(node_ref: &NodeRef) -> Option<NodeRef>
Gets the right sibling of a node.
Sourcepub fn init_base_node_owner(node_ref: &NodeRef)
pub fn init_base_node_owner(node_ref: &NodeRef)
Initializes the owner weak refs for a base node’s MatchedNodes. Must be called after the node is wrapped in Rc.