pub struct NodeRef { /* private fields */ }Expand description
Represents a referene to a node in the document.
Implementations§
Source§impl NodeRef
impl NodeRef
Sourcepub fn append_child(self, arena: &mut Arena, child_ref: NodeRef)
pub fn append_child(self, arena: &mut Arena, child_ref: NodeRef)
Appends a child node to this node.
§Panics
Panics if the operation fails(e.g. due to invalid NodeRef).
Sourcepub fn try_append_child(
self,
arena: &mut Arena,
child_ref: NodeRef,
) -> Result<()>
pub fn try_append_child( self, arena: &mut Arena, child_ref: NodeRef, ) -> Result<()>
Appends a child node to this node.
Sourcepub fn replace_child(
self,
arena: &mut Arena,
target_ref: NodeRef,
replacer_ref: NodeRef,
)
pub fn replace_child( self, arena: &mut Arena, target_ref: NodeRef, replacer_ref: NodeRef, )
Replace a child node with another node. Replaced child will be hard removed.
§Panics
Panics if the operation fails(e.g. due to invalid NodeRef).
Sourcepub fn try_replace_child(
self,
arena: &mut Arena,
target_ref: NodeRef,
replacer_ref: NodeRef,
) -> Result<()>
pub fn try_replace_child( self, arena: &mut Arena, target_ref: NodeRef, replacer_ref: NodeRef, ) -> Result<()>
Replace a child node with another node. Replaced child will be hard removed.
Sourcepub fn insert_before(
self,
arena: &mut Arena,
target_ref: NodeRef,
insertee_ref: NodeRef,
)
pub fn insert_before( self, arena: &mut Arena, target_ref: NodeRef, insertee_ref: NodeRef, )
Inserts a child node before a target node.
§Panics
Panics if the operation fails(e.g. due to invalid NodeRef).
Sourcepub fn try_insert_before(
self,
arena: &mut Arena,
target_ref: NodeRef,
insertee_ref: NodeRef,
) -> Result<()>
pub fn try_insert_before( self, arena: &mut Arena, target_ref: NodeRef, insertee_ref: NodeRef, ) -> Result<()>
Inserts a child node before a target node.
Sourcepub fn insert_after(
self,
arena: &mut Arena,
target_ref: NodeRef,
insertee_ref: NodeRef,
)
pub fn insert_after( self, arena: &mut Arena, target_ref: NodeRef, insertee_ref: NodeRef, )
Inserts a child node after a target node.
§Panics
Panics if the operation fails(e.g. due to invalid NodeRef).
Sourcepub fn try_insert_after(
self,
arena: &mut Arena,
target_ref: NodeRef,
insertee_ref: NodeRef,
) -> Result<()>
pub fn try_insert_after( self, arena: &mut Arena, target_ref: NodeRef, insertee_ref: NodeRef, ) -> Result<()>
Inserts a child node after a target node.
Sourcepub fn remove(self, arena: &mut Arena)
pub fn remove(self, arena: &mut Arena)
Removes this node from the document. This does not remove its children. This does not remove the node from Arena.
§Panics
Panics if the operation fails(e.g. due to invalid NodeRef).
Sourcepub fn try_remove(self, arena: &mut Arena) -> Result<()>
pub fn try_remove(self, arena: &mut Arena) -> Result<()>
Removes this node from the document. This does not remove its children. This does not remove the node from Arena.
Sourcepub fn delete(self, arena: &mut Arena)
pub fn delete(self, arena: &mut Arena)
Deletes this node from the document, including all its children. This removes the node from Arena.
§Panics
Panics if the operation fails(e.g. due to invalid NodeRef).
Sourcepub fn try_delete(self, arena: &mut Arena) -> Result<()>
pub fn try_delete(self, arena: &mut Arena) -> Result<()>
Removes this node from the document, including all its children. This removes the node from Arena.
pub fn merge_or_append_text(self, arena: &mut Arena, index: Index)
pub fn try_merge_or_append_text( self, arena: &mut Arena, index: Index, ) -> Result<()>
Sourcepub fn merge_or_insert_after_text(
self,
arena: &mut Arena,
target_ref: NodeRef,
index: Index,
)
pub fn merge_or_insert_after_text( self, arena: &mut Arena, target_ref: NodeRef, index: Index, )
Merges a given index into the text node after the target node if it can be merged, otherwise creates a new Text node and inserts it after the target node.
Panics if the operation fails(e.g. due to invalid NodeRef).
Sourcepub fn try_merge_or_insert_after_text(
self,
arena: &mut Arena,
target_ref: NodeRef,
index: Index,
) -> Result<()>
pub fn try_merge_or_insert_after_text( self, arena: &mut Arena, target_ref: NodeRef, index: Index, ) -> Result<()>
Merges a given index into the text node after the target node if it can be merged, otherwise creates a new Text node and inserts it after the target node.
Sourcepub fn merge_or_insert_before_text(
self,
arena: &mut Arena,
target_ref: NodeRef,
index: Index,
)
pub fn merge_or_insert_before_text( self, arena: &mut Arena, target_ref: NodeRef, index: Index, )
Merges a given index into the text node before the target node if it can be merged, otherwise creates a new Text node and inserts it before the target node.
§Panics
Panics if the operation fails(e.g. due to invalid NodeRef).
Trait Implementations§
Source§impl Index<NodeRef> for Arena
Implements indexing for Arena to access nodes by NodeRef.
This panics if the NodeRef is invalid.
impl Index<NodeRef> for Arena
Implements indexing for Arena to access nodes by NodeRef. This panics if the NodeRef is invalid.
Source§impl IndexMut<NodeRef> for Arena
Implements mutable indexing for Arena to access nodes by NodeRef.
This panics if the NodeRef is invalid.
impl IndexMut<NodeRef> for Arena
Implements mutable indexing for Arena to access nodes by NodeRef. This panics if the NodeRef is invalid.