pub struct NodeSet { /* private fields */ }Expand description
An XPath node-set.
Internally stored as a sorted, deduplicated Vec of node pointers in document order.
Implementations§
Source§impl NodeSet
impl NodeSet
Sourcepub fn iter(&self) -> impl Iterator<Item = *mut _xmlNode> + '_
pub fn iter(&self) -> impl Iterator<Item = *mut _xmlNode> + '_
Iterate over the nodes in document order.
Sourcepub fn get(&self, index: usize) -> Option<*mut _xmlNode>
pub fn get(&self, index: usize) -> Option<*mut _xmlNode>
Return the node at index in document order, or None if out of bounds.
Sourcepub fn contains(&self, node: *mut _xmlNode) -> bool
pub fn contains(&self, node: *mut _xmlNode) -> bool
Return true if the given node is in the node-set.
Sourcepub fn push(&mut self, node: *mut _xmlNode)
pub fn push(&mut self, node: *mut _xmlNode)
Add a node to the set, maintaining document order and uniqueness.
Sourcepub fn sort(&mut self)
pub fn sort(&mut self)
Sort nodes in document order.
§UPSTREAM-PARITY
XPath node-sets are always in document order (XPath 1.0 §3.3). libxml2 maintains this via its node-set insertion/merge logic plus the document-order comparator (xmlXPathNodeSetSort). Sorting by pointer address is NOT document order and breaks downstream ordering guarantees; the oracle-observed symptom is rotated results on the second of two transforms in one process.
Sourcepub unsafe fn to_raw(&self) -> *mut _xmlNodeSet
pub unsafe fn to_raw(&self) -> *mut _xmlNodeSet
Convert to raw C ABI node-set.
SAFETY: The returned pointer must be freed with xmlXPathFreeNodeSet or the owning XPath object must be freed.
§SAFETY
The function touches crate-global state only; it is safe as long as the caller respects the library’s global initialization/cleanup ordering (xmlInitParser before use, xmlCleanupParser only after all users are done).
Violating the global lifecycle ordering, or calling this after teardown or from a signal handler, is undefined behavior.