pub struct BufferDocument<'a> { /* private fields */ }Expand description
Compact, cache-friendly XML document representation.
Built on a flat array of 16-byte Node structs with power-of-2
page addressing. All string data lives in the arena or in the
StringStore; qualified names are deduplicated via QNameTable.
Implementations§
Source§impl<'a> BufferDocument<'a>
impl<'a> BufferDocument<'a>
Sourcepub fn kind(&self) -> DocumentKind
pub fn kind(&self) -> DocumentKind
Returns the document kind (full or fragment).
Sourcepub fn options(&self) -> &BufferDocumentOptions
pub fn options(&self) -> &BufferDocumentOptions
Returns the construction options.
Sourcepub fn schema_set(&self) -> Option<&'a SchemaSet>
pub fn schema_set(&self) -> Option<&'a SchemaSet>
Returns the associated schema set, if any.
Sourcepub fn first_child_of(&self, parent: u32) -> u32
pub fn first_child_of(&self, parent: u32) -> u32
Returns the first child of parent (always parent + 1).
This relies on the document-order layout: the first child node is stored immediately after its parent.
Sourcepub fn first_content_child_of(&self, parent: u32) -> Option<u32>
pub fn first_content_child_of(&self, parent: u32) -> Option<u32>
Returns the first content (non-attribute) child of parent, or
None if the element has no children.
Attribute pairs precede content children in document order.
This method skips over them by walking the next_sibling chain
of attribute nodes until a non-attribute child is found.
Sourcepub fn subtree_end(&self, elem: u32) -> u32
pub fn subtree_end(&self, elem: u32) -> u32
Returns the flat index one past the last node in the subtree
rooted at elem.
Walks ancestors until a node with a next_sibling is found and
returns that sibling. If the root is reached without finding a
sibling, returns self.nodes.len() (end of document).
Sourcepub fn get_element_by_id(&self, id: &str) -> Option<u32>
pub fn get_element_by_id(&self, id: &str) -> Option<u32>
Looks up an element node by its xml:id value.
Creates a navigator positioned at the document root.
Creates a navigator positioned at the given node reference.
Sourcepub fn from_reader<R: BufRead>(
reader: R,
arena: &'a Bump,
names: &'a NameTable,
options: BufferDocumentOptions,
schema_set: Option<&'a SchemaSet>,
) -> Result<Self, BufferDocumentError>
pub fn from_reader<R: BufRead>( reader: R, arena: &'a Bump, names: &'a NameTable, options: BufferDocumentOptions, schema_set: Option<&'a SchemaSet>, ) -> Result<Self, BufferDocumentError>
Parses an XML document from a reader into a BufferDocument.
Sourcepub fn from_reader_default<R: BufRead>(
reader: R,
arena: &'a Bump,
names: &'a NameTable,
) -> Result<Self, BufferDocumentError>
pub fn from_reader_default<R: BufRead>( reader: R, arena: &'a Bump, names: &'a NameTable, ) -> Result<Self, BufferDocumentError>
Parses an XML document from a reader with default options.