use tokenizer::{Attribute, QName};
use std::borrow::Cow;
use tendril::StrTendril;
pub use self::NodeOrText::{AppendNode, AppendText};
pub enum NodeOrText<Handle> {
AppendNode(Handle),
AppendText(StrTendril),
}
#[derive(PartialEq, Eq, Copy, Clone, Hash, Debug)]
pub enum NextParserState {
Suspend,
Continue,
}
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 {
NextParserState::Continue
}
}
pub trait Tracer {
type Handle;
fn trace_handle(&self, node: Self::Handle);
}