pub type NodeId = u32;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(u8)]
pub enum NodeType {
Element = 0x01,
Text = 0x03,
Cdata = 0x04,
ProcessingInstruction = 0x07,
Comment = 0x08,
Document = 0x09,
Doctype = 0x0A,
Other = 0x0B,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum TagKey<'t> {
Known(u16),
Name(&'t str),
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Attr<'t> {
pub qualified_name: &'t str,
pub local_name: &'t str,
pub namespace_uri: &'t str,
pub value: &'t str,
}
pub trait Tree: Sync {
fn len(&self) -> usize;
fn is_empty(&self) -> bool {
self.len() == 0
}
fn kind(&self, n: NodeId) -> NodeType;
fn parent(&self, n: NodeId) -> Option<NodeId>;
fn first_child(&self, n: NodeId) -> Option<NodeId>;
fn next_sibling(&self, n: NodeId) -> Option<NodeId>;
fn prev_sibling(&self, n: NodeId) -> Option<NodeId>;
fn qualified_name(&self, n: NodeId) -> &str;
fn local_name(&self, n: NodeId) -> &str;
fn namespace_uri(&self, n: NodeId) -> &str;
fn tag_key(&self, n: NodeId) -> TagKey<'_>;
fn attribute_count(&self, n: NodeId) -> u32;
fn attribute(&self, n: NodeId, i: u32) -> Option<Attr<'_>>;
fn namespace_declaration_count(&self, _n: NodeId) -> u32 {
0
}
fn namespace_declaration(&self, _n: NodeId, _i: u32) -> Option<(&str, &str)> {
None
}
fn data(&self, n: NodeId) -> &str;
fn pi_target(&self, n: NodeId) -> Option<&str>;
fn is_xml(&self) -> bool;
fn id(&self, n: NodeId) -> Option<&str>;
fn lang(&self, n: NodeId) -> Option<&str>;
}