[−][src]Struct marked::NodeRef
A Node
within Document
lifetime reference.
This provides convenient but necessarily read-only access.
Implementations
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>(
&self,
predicate: P
) -> impl Iterator<Item = NodeRef<'a>> + 'a where
P: FnMut(&NodeRef<'a>) -> bool + 'a,
[src]
&self,
predicate: P
) -> impl Iterator<Item = NodeRef<'a>> + 'a where
P: FnMut(&NodeRef<'a>) -> bool + 'a,
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>(&self, predicate: P) -> Selector<'a, P>ⓘ where
P: FnMut(&NodeRef<'a>) -> bool + 'a,
[src]
P: FnMut(&NodeRef<'a>) -> bool + 'a,
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>(&self, predicate: P) -> Option<NodeRef<'a>> where
P: FnMut(&NodeRef<'a>) -> bool,
[src]
P: FnMut(&NodeRef<'a>) -> bool,
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>(&self, predicate: P) -> Option<NodeRef<'a>> where
P: FnMut(&NodeRef<'a>) -> bool + 'a,
[src]
P: FnMut(&NodeRef<'a>) -> bool + 'a,
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(&self) -> impl Iterator<Item = NodeRef<'a>> + 'a
[src]
Return an iterator over node's direct children.
Will be empty if the node does not (or can not) have children.
pub fn descendants(&self) -> Descender<'a>ⓘ
[src]
Return an iterator over all descendants in tree order, starting with the specified node.
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(&self) -> Option<NodeRef<'a>>
[src]
Return any parent node or None.
pub fn prev_sibling(&self) -> Option<NodeRef<'a>>
[src]
Return any previous (left) sibling node or None.
pub fn next_sibling(&self) -> Option<NodeRef<'a>>
[src]
Return any subsequent next (right) sibling node or None.
pub fn text(&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(&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]
W: Write,
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]
impl PartialEq<NodeRef<'_>> for NodeRef<'_>
[src]
Equivalence is defined here for NodeRef
s if and only if they reference
the same Document
(by identity) and with equal NodeId
s.
pub fn eq(&self, other: &Self) -> bool
[src]
#[must_use]pub fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a> Serialize for NodeRef<'a>
[src]
pub fn serialize<S>(
&self,
serializer: &mut S,
traversal_scope: TraversalScope
) -> Result<()> where
S: Serializer,
[src]
&self,
serializer: &mut S,
traversal_scope: TraversalScope
) -> Result<()> where
S: Serializer,
impl<'a> ToString for NodeRef<'a>
[src]
Implemented via NodeRef::serialize
.
Auto Trait Implementations
impl<'a> !RefUnwindSafe for NodeRef<'a>
[src]
impl<'a> !Send for NodeRef<'a>
[src]
impl<'a> !Sync for NodeRef<'a>
[src]
impl<'a> Unpin for NodeRef<'a>
[src]
impl<'a> !UnwindSafe for NodeRef<'a>
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,