Struct kuchiki::Node [−][src]
pub struct Node { /* fields omitted */ }
A node inside a DOM-like tree.
Methods
impl Node
[src]
impl Node
pub fn data(&self) -> &NodeData
[src]
pub fn data(&self) -> &NodeData
Return a reference to this node’s node-type-specific data.
pub fn as_element(&self) -> Option<&ElementData>
[src]
pub fn as_element(&self) -> Option<&ElementData>
If this node is an element, return a reference to element-specific data.
pub fn as_text(&self) -> Option<&RefCell<String>>
[src]
pub fn as_text(&self) -> Option<&RefCell<String>>
If this node is a text node, return a reference to its contents.
pub fn as_comment(&self) -> Option<&RefCell<String>>
[src]
pub fn as_comment(&self) -> Option<&RefCell<String>>
If this node is a comment, return a reference to its contents.
pub fn as_doctype(&self) -> Option<&Doctype>
[src]
pub fn as_doctype(&self) -> Option<&Doctype>
If this node is a document, return a reference to doctype-specific data.
pub fn as_document(&self) -> Option<&DocumentData>
[src]
pub fn as_document(&self) -> Option<&DocumentData>
If this node is a document, return a reference to document-specific data.
pub fn parent(&self) -> Option<NodeRef>
[src]
pub fn parent(&self) -> Option<NodeRef>
Return a reference to the parent node, unless this node is the root of the tree.
pub fn first_child(&self) -> Option<NodeRef>
[src]
pub fn first_child(&self) -> Option<NodeRef>
Return a reference to the first child of this node, unless it has no child.
pub fn last_child(&self) -> Option<NodeRef>
[src]
pub fn last_child(&self) -> Option<NodeRef>
Return a reference to the last child of this node, unless it has no child.
pub fn previous_sibling(&self) -> Option<NodeRef>
[src]
pub fn previous_sibling(&self) -> Option<NodeRef>
Return a reference to the previous sibling of this node, unless it is a first child.
pub fn next_sibling(&self) -> Option<NodeRef>
[src]
pub fn next_sibling(&self) -> Option<NodeRef>
Return a reference to the previous sibling of this node, unless it is a last child.
pub fn detach(&self)
[src]
pub fn detach(&self)
Detach a node from its parent and siblings. Children are not affected.
To remove a node and its descendants, detach it and drop any strong reference to it.
Trait Implementations
impl Debug for Node
[src]
impl Debug for Node
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>
[src]
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>
Formats the value using the given formatter. Read more
impl Drop for Node
[src]
impl Drop for Node
Prevent implicit recursion when dropping nodes to avoid overflowing the stack.
The implicit drop is correct, but recursive. In the worst case (where no node has both a next sibling and a child), a tree of a few tens of thousands of nodes could cause a stack overflow.
This Drop
implementations makes sure the recursion does not happen.
Instead, it has an explicit Vec<Rc<Node>>
stack to traverse the subtree,
but only following Rc<Node>
references that are "unique":
that have a strong reference count of 1.
Those are the nodes that would have been dropped recursively.
The stack holds ancestors of the current node rather than preceding siblings, on the assumption that large document trees are typically wider than deep.