[][src]Struct kuchiki::Node

pub struct Node { /* fields omitted */ }

A node inside a DOM-like tree.

Implementations

impl Node[src]

pub fn data(&self) -> &NodeData[src]

Return a reference to this node’s node-type-specific data.

pub fn as_element(&self) -> Option<&ElementData>[src]

If this node is an element, return a reference to element-specific data.

pub fn as_text(&self) -> Option<&RefCell<String>>[src]

If this node is a text node, return a reference to its contents.

pub fn as_comment(&self) -> Option<&RefCell<String>>[src]

If this node is a comment, return a reference to its contents.

pub fn as_doctype(&self) -> Option<&Doctype>[src]

If this node is a document, return a reference to doctype-specific data.

pub fn as_document(&self) -> Option<&DocumentData>[src]

If this node is a document, return a reference to document-specific data.

pub fn parent(&self) -> Option<NodeRef>[src]

Return a reference to the parent node, unless this node is the root of the tree.

pub fn first_child(&self) -> Option<NodeRef>[src]

Return a reference to the first child of this node, unless it has no child.

pub fn last_child(&self) -> Option<NodeRef>[src]

Return a reference to the last child of this node, unless it has no child.

pub fn previous_sibling(&self) -> Option<NodeRef>[src]

Return a reference to the previous sibling of this node, unless it is a first child.

pub fn next_sibling(&self) -> Option<NodeRef>[src]

Return a reference to the next sibling of this node, unless it is a last child.

pub fn detach(&self)[src]

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 Drop for Node[src]

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.

Auto Trait Implementations

impl !RefUnwindSafe for Node

impl !Send for Node

impl !Sync for Node

impl Unpin for Node

impl !UnwindSafe for Node

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.