Skip to main content

TreeSink

Trait TreeSink 

Source
pub trait TreeSink {
    // Required methods
    fn open_tag(
        &mut self,
        tag: Tag,
        name: &str,
        attr_raw: &str,
        self_closing: bool,
    );
    fn close_tag(&mut self, tag: Tag, name: &str);
    fn text(&mut self, content: &str);
    fn comment(&mut self, content: &str);
    fn doctype(&mut self, content: &str);
    fn cdata(&mut self, content: &str);
}
Expand description

Trait for receiving parsed HTML events directly, bypassing Token allocation.

Implementors receive raw parse events (open/close tags, text, etc.) and can build their output structure in a single pass without intermediate Token enum or Vec<Attribute> allocations.

Required Methods§

Source

fn open_tag(&mut self, tag: Tag, name: &str, attr_raw: &str, self_closing: bool)

An opening tag was encountered.

attr_raw is the raw attribute region between the tag name and >. The implementor is responsible for parsing attributes from this slice.

Source

fn close_tag(&mut self, tag: Tag, name: &str)

A closing tag was encountered.

Source

fn text(&mut self, content: &str)

Raw text content (not entity-decoded).

The implementor is responsible for entity decoding if desired.

Source

fn comment(&mut self, content: &str)

A comment was encountered.

Source

fn doctype(&mut self, content: &str)

A DOCTYPE declaration was encountered.

Source

fn cdata(&mut self, content: &str)

A CDATA section was encountered.

Implementors§