Skip to main content

XPathValue

Enum XPathValue 

Source
pub enum XPathValue {
    NodeSet(Vec<usize>),
    ForeignNodeSet(Vec<*const Node<'static>>),
    String(String),
    Number(Numeric),
    Boolean(bool),
    Typed(Box<TypedAtomic>),
    Sequence(Vec<Value>),
    IntRange {
        lo: i64,
        hi: i64,
    },
    Map(Box<Vec<(Value, Value)>>),
    Array(Box<Vec<Value>>),
    Function(Box<FunctionItem>),
}

Variants§

§

NodeSet(Vec<usize>)

§

ForeignNodeSet(Vec<*const Node<'static>>)

Result of document(URI) — nodes that live in a doc the engine’s current DocIndex doesn’t cover. The engine treats these opaquely; ops that need traversal/string-value delegate to the bindings (compat looks up the right DocIndex via its doc registry). Pointer-identity dedup, no document order across docs.

§

String(String)

§

Number(Numeric)

§

Boolean(bool)

§

Typed(Box<TypedAtomic>)

XPath 2.0 typed atomic value — carries the source XSD type tag so instance of xs:T, cast as xs:T, and other type-aware operators can answer schema questions about it. Numeric / boolean / string operations treat a Typed value as its underlying representation (see value_to_number, value_to_string, value_to_bool for the lowering rules) so XPath 1.0-style consumers keep working unchanged.

Boxed to keep sizeof(Value) at the existing ~32-byte footprint — non-2.0 hot paths that never produce typed values pay no memory-bandwidth tax on every Value clone / push. The cost shifts to one heap allocation per xs:T(…) call, which is bounded and small.

§

Sequence(Vec<Value>)

XPath 2.0 §2.4 heterogeneous sequence of typed / atomic items. Produced by the parenthesised sequence constructor (a, b, c) when at least one item is a typed atomic — keeps each item’s type tag intact so instance of / subsequence / data() round-trip correctly. When every item is a node or every item is an untyped atomic, the existing NodeSet / single Value paths are still used to avoid the per-item Value allocation overhead.

Invariant: items are themselves never Sequence — sequences flatten at construction (XPath 2.0 §3.3.1).

§

IntRange

XPath 2.0 §3.3.1 integer range (m to n) carried as bounds instead of an expanded list. Stays compact for the W3C Unicode-category test families that iterate 1 to 0x10FFFF — materialising would cost millions of Value allocations and burn the per-thread eval-step budget on tree construction alone. Consumers that need positional / set semantics (subsequence, document-order comparisons, count of a mixed sequence) expand via [items_of]; consumers that can stay arithmetic (count, sum, simple-map first projection) special-case the variant to keep things O(1).

Invariant: lo <= hi — empty ranges normalise to NodeSet(vec![]) at construction so consumers never see an IntRange they need to test for emptiness.

Fields

§lo: i64
§hi: i64
§

Map(Box<Vec<(Value, Value)>>)

XPath 3.1 §17.1 map — an ordered list of (key, value) entries. Keys are single atomic values; values are arbitrary sequences (themselves Values). Lookup compares keys by value (map_key_eq). Boxed to keep sizeof(Value) small.

§

Array(Box<Vec<Value>>)

XPath 3.1 §17.3 array — an ordered list of members, each an arbitrary sequence (a Value). Indexed 1-based via ?.

§

Function(Box<FunctionItem>)

XPath 3.1 function item — an inline function (with its captured closure), a named-function reference, or a partial application.

Implementations§

Source§

impl Value

Source

pub fn untyped(self) -> Value

Strip a typed wrapper, returning the underlying untyped Value. Numeric typed → Number; boolean typed → Boolean; otherwise → String (the typed value’s lexical form, moved out without cloning). A Sequence collapses to a NodeSet only when every item is already a node (no atomic-sequence lowering); a singleton Sequence unwraps to its sole item. Non-Typed, non-Sequence values pass through unchanged.

Trait Implementations§

Source§

impl Clone for Value

Source§

fn clone(&self) -> Value

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 Value

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Value

§

impl !Send for Value

§

impl !Sync for Value

§

impl !UnwindSafe for Value

§

impl Freeze for Value

§

impl Unpin for Value

§

impl UnsafeUnpin for Value

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> 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> Same for T

Source§

type Output = T

Should always be Self
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 = 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.