[−][src]Struct marked::NodeRef
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]
&'a 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>(&'a 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>(&'a 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>(&'a 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(&'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]
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.
impl<'a> Serialize for NodeRef<'a>
[src]
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>
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]
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,
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.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
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.
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>,