pub struct TreeBuilder { /* private fields */ }Expand description
Builds a DOM tree from a token stream.
Maintains an open-elements stack and processes each token to either push new nodes, pop closed elements, or append text/comment/doctype nodes.
Implementations§
Source§impl TreeBuilder
impl TreeBuilder
Sourcepub fn with_capacity_hint(input_len: usize) -> Self
pub fn with_capacity_hint(input_len: usize) -> Self
Create a tree builder with capacity tuned to the expected input size.
Uses heuristics to estimate node, text, and attribute counts from the input byte length, reducing reallocations for large documents.
Sourcepub fn enable_tag_index(&mut self)
pub fn enable_tag_index(&mut self)
Enable the inline tag index for O(1) tag lookups after parsing.
When enabled, each element’s tag is indexed during tree construction,
eliminating the need for a separate DFS pass in
DocumentIndex::build.
Sourcepub fn set_source(&mut self, input: &str)
pub fn set_source(&mut self, input: &str)
Enable source-backed text nodes.
Stores an owned copy of input in the arena. Text nodes whose content
is borrowed from input (entity-free) will reference the source
instead of copying to the text slab.
Sourcepub fn set_source_ptr(&mut self, input: &str)
pub fn set_source_ptr(&mut self, input: &str)
Set source pointer tracking without copying data to the arena.
Use this with Arena::set_source_owned after tokenization to
avoid a redundant memcpy when the caller owns the input String.