Struct kuchiki::NodeRef [] [src]

pub struct NodeRef(pub Rc<Node>);

A strong reference to a node.

A node is destroyed when the last strong reference to it dropped.

Each node holds a strong reference to its first child and next sibling (if any), but only a weak reference to its last child, previous sibling, and parent. This is to avoid strong reference cycles, which would cause memory leaks.

As a result, a single NodeRef is sufficient to keep alive a node and nodes that are after it in tree order (its descendants, its following siblings, and their descendants) but not other nodes in a tree.

To avoid detroying nodes prematurely, programs typically hold a strong reference to the root of a document until they’re done with that document.

Methods

impl NodeRef
[src]

[src]

Return an iterator of references to this node and its ancestors.

[src]

Return an iterator of references to this node’s ancestors.

[src]

Return an iterator of references to this node and the siblings before it.

[src]

Return an iterator of references to this node’s siblings before it.

[src]

Return an iterator of references to this node and the siblings after it.

[src]

Return an iterator of references to this node’s siblings after it.

[src]

Return an iterator of references to this node’s children.

[src]

Return an iterator of references to this node and its descendants, in tree order.

Parent nodes appear before the descendants.

Note: this is the NodeEdge::Start items from traverse().

[src]

Return an iterator of references to this node’s descendants, in tree order.

Parent nodes appear before the descendants.

Note: this is the NodeEdge::Start items from traverse().

[src]

Return an iterator of the start and end edges of this node and its descendants, in tree order.

[src]

Return an iterator of the start and end edges of this node’s descendants, in tree order.

[src]

Return an iterator of the inclusive descendants element that match the given selector list.

[src]

Return the first inclusive descendants element that match the given selector list.

impl NodeRef
[src]

[src]

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

[src]

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

[src]

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

[src]

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

[src]

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

impl NodeRef
[src]

[src]

Serialize this node and its descendants in HTML syntax to the given stream.

[src]

Serialize this node and its descendants in HTML syntax to a new file at the given path.

impl NodeRef
[src]

[src]

Create a new node.

[src]

Create a new element node.

[src]

Create a new text node.

[src]

Create a new comment node.

[src]

Create a new processing instruction node.

[src]

Create a new doctype node.

[src]

Create a new document node.

[src]

Return the concatenation of all text nodes in this subtree.

impl NodeRef
[src]

[src]

Append a new child to this node, after existing children.

The new child is detached from its previous position.

[src]

Prepend a new child to this node, before existing children.

The new child is detached from its previous position.

[src]

Insert a new sibling after this node.

The new sibling is detached from its previous position.

[src]

Insert a new sibling before this node.

The new sibling is detached from its previous position.

Methods from Deref<Target = Node>

[src]

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

[src]

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

[src]

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

[src]

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

[src]

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

[src]

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

[src]

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

[src]

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

[src]

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

[src]

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

[src]

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

[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 Serialize for NodeRef
[src]

[src]

impl ToString for NodeRef
[src]

[src]

Converts the given value to a String. Read more

impl Clone for NodeRef
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for NodeRef
[src]

[src]

Formats the value using the given formatter.

impl Deref for NodeRef
[src]

The resulting type after dereferencing.

[src]

Dereferences the value.

impl Eq for NodeRef
[src]

impl PartialEq for NodeRef
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

1.0.0
[src]

This method tests for !=.