rama_http/protocols/html/tokenizer/sink.rs
1//! The sink that receives tokens from the [`Tokenizer`](super::Tokenizer).
2
3use super::token::{Cdata, Comment, Doctype, EndTag, StartTag, Text};
4
5/// Receives token events as the tokenizer scans HTML.
6///
7/// Every method has a default no-op body, so a sink only overrides the
8/// events it cares about. Token views borrow the input and are valid only
9/// for the duration of the call.
10pub trait TokenSink {
11 /// Called for each start tag (`<a href="…">`, `<br/>`).
12 fn start_tag(&mut self, tag: &StartTag<'_>) {
13 let _ = tag;
14 }
15
16 /// Called for each end tag (`</a>`).
17 fn end_tag(&mut self, tag: &EndTag<'_>) {
18 let _ = tag;
19 }
20
21 /// Called for each run of character data.
22 fn text(&mut self, text: &Text<'_>) {
23 let _ = text;
24 }
25
26 /// Called for each comment.
27 fn comment(&mut self, comment: &Comment<'_>) {
28 let _ = comment;
29 }
30
31 /// Called for each CDATA section (only inside SVG/MathML foreign content).
32 fn cdata(&mut self, cdata: &Cdata<'_>) {
33 let _ = cdata;
34 }
35
36 /// Called for each doctype declaration.
37 fn doctype(&mut self, doctype: &Doctype<'_>) {
38 let _ = doctype;
39 }
40}