pub struct DocumentIndex<'a> { /* private fields */ }Available on crate features
css-selector or xpath only.Expand description
CSS selector and XPath engine. Pre-built index for O(1) id, class, and tag lookups.
Build once with a single DFS pass, reuse for many lookups.
Implementations§
Source§impl<'a> DocumentIndex<'a>
impl<'a> DocumentIndex<'a>
Sourcepub fn build(doc: &'a Document) -> DocumentIndex<'a>
pub fn build(doc: &'a Document) -> DocumentIndex<'a>
Build an index from a document by scanning all nodes in a single pass.
If the arena has a pre-built tag index (constructed inline during tree building), the tag map is copied directly — avoiding the tag scan.
Sourcepub fn find_by_id(&self, _doc: &Document, id: &str) -> Option<NodeRef<'a>>
pub fn find_by_id(&self, _doc: &Document, id: &str) -> Option<NodeRef<'a>>
Look up a node by its id attribute in O(1).
The doc argument is retained for compatibility; lookups resolve against
the document used to build this index.
Auto Trait Implementations§
impl<'a> Freeze for DocumentIndex<'a>
impl<'a> RefUnwindSafe for DocumentIndex<'a>
impl<'a> Send for DocumentIndex<'a>
impl<'a> Sync for DocumentIndex<'a>
impl<'a> Unpin for DocumentIndex<'a>
impl<'a> UnsafeUnpin for DocumentIndex<'a>
impl<'a> UnwindSafe for DocumentIndex<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more