[][src]Struct marked::NodeRef

pub struct NodeRef<'a> { /* fields omitted */ }

A Node within Document lifetime reference.

This provides convenient but necessarily read-only access.

Methods

impl<'a> NodeRef<'a>[src]

pub fn new(doc: &'a Document, id: NodeId) -> Self[src]

Constructor.

pub fn id(&self) -> NodeId[src]

Return the associated NodeId.

pub fn select_children<P>(
    &'a self,
    predicate: P
) -> impl Iterator<Item = NodeRef<'a>> + 'a where
    P: FnMut(&NodeRef<'a>) -> bool + 'a, 
[src]

Return an iterator over the direct children of this node that match the specified predicate.

This is a convenence short hand for children().filter(predicate). The "filter" name is avoided in deference to the (mutating) Document::filter method.

pub fn select<P>(&'a self, predicate: P) -> Selector<'a, P> where
    P: FnMut(&NodeRef<'a>) -> bool + 'a, 
[src]

Return an iterator over all decendents of this node that match the specified predicate.

When element nodes fail the predicate, their children are scanned, depth-first, in search of all matches.

pub fn find_child<P>(&'a self, predicate: P) -> Option<NodeRef<'a>> where
    P: FnMut(&NodeRef<'a>) -> bool
[src]

Find the first direct child of this node that matches the specified predicate.

This is a convenence short hand for children().find(predicate).

pub fn find<P>(&'a self, predicate: P) -> Option<NodeRef<'a>> where
    P: FnMut(&NodeRef<'a>) -> bool + 'a, 
[src]

Find the first descendant of this node that matches the specified predicate.

When element nodes fail the predicate, their children are scanned, depth-first, in search of the first match.

pub fn children(&'a self) -> impl Iterator<Item = NodeRef<'a>> + 'a[src]

Return an iterator over node's direct children.

Will yield nothing if the node can not or does not have children.

pub fn node_and_ancestors(&'a self) -> impl Iterator<Item = NodeRef<'a>> + 'a[src]

Return an iterator yielding self and all ancestors, terminating at the document node.

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

Return any parent node or None.

pub fn prev_sibling(&'a self) -> Option<NodeRef<'a>>[src]

Return any previous (left) sibling node or None.

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

Return any subsequent next (right) sibling node or None.

pub fn text(&'a self) -> Option<StrTendril>[src]

Return all decendent text content (character data) of this node.

If this is a Text node, return that text. If this is an Element node or the Document root node, return the concatentation of all text descendants, in tree order. Returns None for all other node types.

pub fn deep_clone(&'a self) -> Document[src]

Create a new independent Document from the ordered sub-tree referenced by self.

impl<'a> NodeRef<'a>[src]

Serialize convenience method.

pub fn serialize<W>(&'a self, writer: &mut W) -> Result<()> where
    W: Write
[src]

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

Methods from Deref<Target = Node>

Trait Implementations

impl<'a> Clone for NodeRef<'a>[src]

impl<'a> Copy for NodeRef<'a>[src]

impl<'_> Debug for NodeRef<'_>[src]

impl<'a> Deref for NodeRef<'a>[src]

type Target = Node

The resulting type after dereferencing.

impl<'_> PartialEq<NodeRef<'_>> for NodeRef<'_>[src]

Equivalence is defined here for NodeRefs if and only if they reference the same Document (by identity) and with equal NodeIds.

impl<'a> Serialize for NodeRef<'a>[src]

impl<'a> ToString for NodeRef<'a>[src]

Implemented via NodeRef::serialize.

Auto Trait Implementations

impl<'a> !RefUnwindSafe for NodeRef<'a>

impl<'a> !Send for NodeRef<'a>

impl<'a> !Sync for NodeRef<'a>

impl<'a> Unpin for NodeRef<'a>

impl<'a> !UnwindSafe for NodeRef<'a>

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> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[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.