Skip to main content

NodeSet

Struct NodeSet 

Source
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

Source

pub const fn new() -> Self

Create an empty node-set.

Source

pub fn singleton(node: *mut _xmlNode) -> Self

Create a node-set containing exactly one node.

Source

pub const fn is_empty(&self) -> bool

Return true if the node-set contains no nodes.

Source

pub const fn len(&self) -> usize

Return the number of nodes in the node-set.

Source

pub fn iter(&self) -> impl Iterator<Item = *mut _xmlNode> + '_

Iterate over the nodes in document order.

Source

pub fn get(&self, index: usize) -> Option<*mut _xmlNode>

Return the node at index in document order, or None if out of bounds.

Source

pub fn first(&self) -> Option<*mut _xmlNode>

Return the first node in document order.

Source

pub fn last(&self) -> Option<*mut _xmlNode>

Return the last node in document order.

Source

pub fn contains(&self, node: *mut _xmlNode) -> bool

Return true if the given node is in the node-set.

Source

pub fn push(&mut self, node: *mut _xmlNode)

Append a node to the set.

This is O(1) and does NOT deduplicate or sort. Callers that need the document-order/unique invariant (axis results are already unique and ordered, but unions and relative-path concatenations are not) call sort once at the boundary. Deferring the sort avoids the O(n² log n) node-set construction cost — the Phase 15.1 XPath perf cliff (count(//item) was ~1000× slower than the oracle because every push re-sorted the growing set).

Source

pub fn extend(&mut self, other: &NodeSet)

Extend with another node-set.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for NodeSet

Source§

fn clone(&self) -> NodeSet

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for NodeSet

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for NodeSet

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.