Skip to main content

BufferDocument

Struct BufferDocument 

Source
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>

Source

pub fn kind(&self) -> DocumentKind

Returns the document kind (full or fragment).

Source

pub fn options(&self) -> &BufferDocumentOptions

Returns the construction options.

Source

pub fn root(&self) -> u32

Returns the root node index.

Source

pub fn schema_set(&self) -> Option<&'a SchemaSet>

Returns the associated schema set, if any.

Source

pub fn names(&self) -> &'a NameTable

Returns the shared name table.

Source

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.

Source

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.

Source

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).

Source

pub fn get_element_by_id(&self, id: &str) -> Option<u32>

Looks up an element node by its xml:id value.

Source

pub fn create_navigator(&self) -> BufferDocNavigator<'_>

Creates a navigator positioned at the document root.

Source

pub fn create_navigator_at(&self, node_ref: u32) -> BufferDocNavigator<'_>

Creates a navigator positioned at the given node reference.

Source

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.

Source

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.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for BufferDocument<'a>

§

impl<'a> !Send for BufferDocument<'a>

§

impl<'a> !Sync for BufferDocument<'a>

§

impl<'a> !UnwindSafe for BufferDocument<'a>

§

impl<'a> Freeze for BufferDocument<'a>

§

impl<'a> Unpin for BufferDocument<'a>

§

impl<'a> UnsafeUnpin for BufferDocument<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> MaybeSendSync for T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.