Skip to main content

TokenSink

Trait TokenSink 

pub trait TokenSink {
    // Provided methods
    fn start_tag(&mut self, tag: &StartTag<'_>) { ... }
    fn end_tag(&mut self, tag: &EndTag<'_>) { ... }
    fn text(&mut self, text: &Text<'_>) { ... }
    fn comment(&mut self, comment: &Comment<'_>) { ... }
    fn cdata(&mut self, cdata: &Cdata<'_>) { ... }
    fn doctype(&mut self, doctype: &Doctype<'_>) { ... }
}
Available on crate features html and http only.
Expand description

Receives token events as the tokenizer scans HTML.

Every method has a default no-op body, so a sink only overrides the events it cares about. Token views borrow the input and are valid only for the duration of the call.

Provided Methods§

fn start_tag(&mut self, tag: &StartTag<'_>)

Called for each start tag (<a href="…">, <br/>).

fn end_tag(&mut self, tag: &EndTag<'_>)

Called for each end tag (</a>).

fn text(&mut self, text: &Text<'_>)

Called for each run of character data.

fn comment(&mut self, comment: &Comment<'_>)

Called for each comment.

fn cdata(&mut self, cdata: &Cdata<'_>)

Called for each CDATA section (only inside SVG/MathML foreign content).

fn doctype(&mut self, doctype: &Doctype<'_>)

Called for each doctype declaration.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§