pub enum Node<'a> {
Tag(HTMLTag<'a>),
Raw(Bytes<'a>),
Comment(Bytes<'a>),
}Expand description
An HTML Node
Variants§
Tag(HTMLTag<'a>)
A regular HTML element/tag
Raw(Bytes<'a>)
Raw text (no particular HTML element)
Comment(Bytes<'a>)
Comment ()
Implementations§
Source§impl<'a> Node<'a>
impl<'a> Node<'a>
Sourcepub fn write_outer_html<W: Write, const MAX_NODES: usize, const MAX_STACK: usize, const MAX_ROOTS: usize, const MAX_IDS: usize, const MAX_CLASSES: usize, const MAX_SELECTOR_NODES: usize>(
&self,
parser: &Parser<'a, MAX_NODES, MAX_STACK, MAX_ROOTS, MAX_IDS, MAX_CLASSES, MAX_SELECTOR_NODES>,
dest: &mut W,
) -> Result
pub fn write_outer_html<W: Write, const MAX_NODES: usize, const MAX_STACK: usize, const MAX_ROOTS: usize, const MAX_IDS: usize, const MAX_CLASSES: usize, const MAX_SELECTOR_NODES: usize>( &self, parser: &Parser<'a, MAX_NODES, MAX_STACK, MAX_ROOTS, MAX_IDS, MAX_CLASSES, MAX_SELECTOR_NODES>, dest: &mut W, ) -> Result
Writes the outer HTML representation of this node without allocating.
Sourcepub fn inner_text<'s, 'p: 's, const MAX_NODES: usize, const MAX_STACK: usize, const MAX_ROOTS: usize, const MAX_IDS: usize, const MAX_CLASSES: usize, const MAX_SELECTOR_NODES: usize>(
&'s self,
parser: &'p Parser<'a, MAX_NODES, MAX_STACK, MAX_ROOTS, MAX_IDS, MAX_CLASSES, MAX_SELECTOR_NODES>,
) -> Cow<'s, str>
pub fn inner_text<'s, 'p: 's, const MAX_NODES: usize, const MAX_STACK: usize, const MAX_ROOTS: usize, const MAX_IDS: usize, const MAX_CLASSES: usize, const MAX_SELECTOR_NODES: usize>( &'s self, parser: &'p Parser<'a, MAX_NODES, MAX_STACK, MAX_ROOTS, MAX_IDS, MAX_CLASSES, MAX_SELECTOR_NODES>, ) -> Cow<'s, str>
Returns the inner text of this node
Sourcepub fn outer_html<'s, const MAX_NODES: usize, const MAX_STACK: usize, const MAX_ROOTS: usize, const MAX_IDS: usize, const MAX_CLASSES: usize, const MAX_SELECTOR_NODES: usize>(
&'s self,
parser: &Parser<'a, MAX_NODES, MAX_STACK, MAX_ROOTS, MAX_IDS, MAX_CLASSES, MAX_SELECTOR_NODES>,
) -> Cow<'s, str>
pub fn outer_html<'s, const MAX_NODES: usize, const MAX_STACK: usize, const MAX_ROOTS: usize, const MAX_IDS: usize, const MAX_CLASSES: usize, const MAX_SELECTOR_NODES: usize>( &'s self, parser: &Parser<'a, MAX_NODES, MAX_STACK, MAX_ROOTS, MAX_IDS, MAX_CLASSES, MAX_SELECTOR_NODES>, ) -> Cow<'s, str>
Returns the outer HTML of this node
Sourcepub fn inner_html<'s, const MAX_NODES: usize, const MAX_STACK: usize, const MAX_ROOTS: usize, const MAX_IDS: usize, const MAX_CLASSES: usize, const MAX_SELECTOR_NODES: usize>(
&'s self,
parser: &Parser<'a, MAX_NODES, MAX_STACK, MAX_ROOTS, MAX_IDS, MAX_CLASSES, MAX_SELECTOR_NODES>,
) -> Cow<'s, str>
pub fn inner_html<'s, const MAX_NODES: usize, const MAX_STACK: usize, const MAX_ROOTS: usize, const MAX_IDS: usize, const MAX_CLASSES: usize, const MAX_SELECTOR_NODES: usize>( &'s self, parser: &Parser<'a, MAX_NODES, MAX_STACK, MAX_ROOTS, MAX_IDS, MAX_CLASSES, MAX_SELECTOR_NODES>, ) -> Cow<'s, str>
Returns the inner HTML of this node
Sourcepub fn children(&self) -> Option<Children<'a, '_>>
pub fn children(&self) -> Option<Children<'a, '_>>
Returns an iterator over subnodes (“children”) of this HTML tag, if this is a tag
Sourcepub fn find_node<F>(&self, parser: &Parser<'a>, f: &mut F) -> Option<NodeHandle>
pub fn find_node<F>(&self, parser: &Parser<'a>, f: &mut F) -> Option<NodeHandle>
Calls the given closure with each tag as parameter
The closure must return a boolean, indicating whether it should stop iterating
Returning true will break the loop and return a handle to the node
Sourcepub fn as_tag_mut(&mut self) -> Option<&mut HTMLTag<'a>>
pub fn as_tag_mut(&mut self) -> Option<&mut HTMLTag<'a>>
Tries to coerce this node into a HTMLTag variant
Sourcepub fn as_comment(&self) -> Option<&Bytes<'a>>
pub fn as_comment(&self) -> Option<&Bytes<'a>>
Tries to coerce this node into a comment, returning the text
Sourcepub fn as_comment_mut(&mut self) -> Option<&mut Bytes<'a>>
pub fn as_comment_mut(&mut self) -> Option<&mut Bytes<'a>>
Tries to coerce this node into a comment, returning the text
Sourcepub fn as_raw(&self) -> Option<&Bytes<'a>>
pub fn as_raw(&self) -> Option<&Bytes<'a>>
Tries to coerce this node into a raw text node, returning the text
“Raw text nodes” are nodes that are not HTML tags, but just text
Sourcepub fn as_raw_mut(&mut self) -> Option<&mut Bytes<'a>>
pub fn as_raw_mut(&mut self) -> Option<&mut Bytes<'a>>
Tries to coerce this node into a mutable raw text node, returning the text
“Raw text nodes” are nodes that are not HTML tags, but just text