Trait xml5ever::tree_builder::interface::TreeSink
[−]
[src]
pub trait TreeSink { type Handle: Clone; type Output; fn finish(self) -> Self::Output; fn parse_error(&mut self, msg: Cow<'static, str>); fn get_document(&mut self) -> Self::Handle; fn elem_name(&self, target: &Self::Handle) -> QName; fn create_element(&mut self, name: QName, attrs: Vec<Attribute>) -> Self::Handle; fn create_comment(&mut self, text: StrTendril) -> Self::Handle; fn create_pi(&mut self, target: StrTendril, data: StrTendril) -> Self::Handle; fn append(&mut self, parent: Self::Handle, child: NodeOrText<Self::Handle>); fn append_doctype_to_document(&mut self,
name: StrTendril,
public_id: StrTendril,
system_id: StrTendril); fn mark_script_already_started(&mut self, _node: Self::Handle) { ... } fn complete_script(&mut self, _node: Self::Handle) -> NextParserState { ... } }
Types which can process tree modifications from the tree builder.
Associated Types
type Handle: Clone
Handle
is a reference to a DOM node. The tree builder requires
that a Handle
implements Clone
to get another reference to
the same node.
type Output
The overall result of parsing.
TODO:This should defualt to Self, but default associated types are not stable yet. (https://github.com/rust-lang/rust/issues/29661)
Required Methods
fn finish(self) -> Self::Output
Consume this sink and return the overall result of parsing.
TODO:This should default to fn finish(self) -> Self::Output { self }
,
but default associated types are not stable yet.
(https://github.com/rust-lang/rust/issues/29661)
fn parse_error(&mut self, msg: Cow<'static, str>)
Signal a parse error.
fn get_document(&mut self) -> Self::Handle
Get a handle to the Document
node.
fn elem_name(&self, target: &Self::Handle) -> QName
What is the name of this element?
Should never be called on a non-element node;
feel free to panic!
.
fn create_element(&mut self, name: QName, attrs: Vec<Attribute>) -> Self::Handle
Create an element.
fn create_comment(&mut self, text: StrTendril) -> Self::Handle
Create a comment node.
fn create_pi(&mut self, target: StrTendril, data: StrTendril) -> Self::Handle
Create a Processing Instruction node.
fn append(&mut self, parent: Self::Handle, child: NodeOrText<Self::Handle>)
Append a node as the last child of the given node. If this would produce adjacent sibling text nodes, it should concatenate the text instead.
The child node will not already have a parent.
fn append_doctype_to_document(&mut self,
name: StrTendril,
public_id: StrTendril,
system_id: StrTendril)
name: StrTendril,
public_id: StrTendril,
system_id: StrTendril)
Append a DOCTYPE
element to the Document
node.
Provided Methods
fn mark_script_already_started(&mut self, _node: Self::Handle)
Mark a HTML <script>
as "already started".
fn complete_script(&mut self, _node: Self::Handle) -> NextParserState
Indicate that a script
element is complete.
Implementors
impl TreeSink for RcDom