Skip to main content

XPathValue

Enum XPathValue 

Source
pub enum XPathValue<N: DomNavigator> {
    Empty,
    Item(XmlItem<N>),
    Sequence(Vec<XmlItem<N>>),
}
Expand description

XPath value representing a function result.

This enum represents the result of evaluating an XPath expression or function. It can be empty, a single item, or a sequence of items.

Variants§

§

Empty

Empty sequence

§

Item(XmlItem<N>)

Single item (node or atomic value)

§

Sequence(Vec<XmlItem<N>>)

Sequence of items (materialized)

Implementations§

Source§

impl<N: DomNavigator> XPathValue<N>

Source

pub fn empty() -> Self

Create an empty value

Source

pub fn from_item(item: XmlItem<N>) -> Self

Create a value from a single item

Source

pub fn from_atomic(value: XmlValue) -> Self

Create a value from an atomic XmlValue

Source

pub fn from_node(node: N) -> Self

Create a value from a node

Source

pub fn from_sequence(items: Vec<XmlItem<N>>) -> Self

Create a value from a sequence of items

Source

pub fn boolean(b: bool) -> Self

Create a boolean value

Source

pub fn string(s: impl Into<String>) -> Self

Create a string value

Source

pub fn integer(i: impl Into<BigInt>) -> Self

Create an integer value

Source

pub fn decimal(d: Decimal) -> Self

Create a decimal value

Source

pub fn double(d: f64) -> Self

Create a double value

Source

pub fn is_empty(&self) -> bool

Check if this value is empty

Source

pub fn len(&self) -> usize

Get the count of items

Source

pub fn is_single(&self) -> bool

Check if this is a single item

Source

pub fn into_vec(self) -> Vec<XmlItem<N>>

Convert to a Vec of items

Source

pub fn as_slice(&self) -> &[XmlItem<N>]

Get a reference to items as a slice

Source

pub fn first(&self) -> Option<&XmlItem<N>>

Try to get the first item

Source

pub fn as_str(&self) -> Option<String>

Try to extract a string from a single atomic item.

Returns None if:

  • The value is empty
  • The value is a sequence
  • The item is a node (not atomic)
  • The atomic value is not a string type
Source

pub fn as_bool(&self) -> Option<bool>

Try to extract a boolean from a single atomic item.

Returns None if the value is not a single atomic boolean.

Source

pub fn as_f64(&self) -> Option<f64>

Try to extract a double from a single atomic item.

Returns None if the value is not a single atomic numeric value.

Source

pub fn as_integer(&self) -> Option<BigInt>

Try to extract an integer from a single atomic item.

Returns None if the value is not a single atomic integer.

Trait Implementations§

Source§

impl<N: Clone + DomNavigator> Clone for XPathValue<N>

Source§

fn clone(&self) -> XPathValue<N>

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<N: Debug + DomNavigator> Debug for XPathValue<N>

Source§

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

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

impl<N: DomNavigator> From<&str> for XPathValue<N>

Source§

fn from(s: &str) -> Self

Converts to this type from the input type.
Source§

impl<N: DomNavigator> From<()> for XPathValue<N>

Source§

fn from(_: ()) -> Self

Converts to this type from the input type.
Source§

impl<N: DomNavigator> From<BigInt> for XPathValue<N>

Source§

fn from(i: BigInt) -> Self

Converts to this type from the input type.
Source§

impl<N: DomNavigator> From<String> for XPathValue<N>

Source§

fn from(s: String) -> Self

Converts to this type from the input type.
Source§

impl<N: DomNavigator> From<bool> for XPathValue<N>

Source§

fn from(b: bool) -> Self

Converts to this type from the input type.
Source§

impl<N: DomNavigator> From<f32> for XPathValue<N>

Source§

fn from(f: f32) -> Self

Converts to this type from the input type.
Source§

impl<N: DomNavigator> From<f64> for XPathValue<N>

Source§

fn from(d: f64) -> Self

Converts to this type from the input type.
Source§

impl<N: DomNavigator> From<i32> for XPathValue<N>

Source§

fn from(i: i32) -> Self

Converts to this type from the input type.
Source§

impl<N: DomNavigator> From<i64> for XPathValue<N>

Source§

fn from(i: i64) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<N> Freeze for XPathValue<N>
where N: Freeze,

§

impl<N> RefUnwindSafe for XPathValue<N>
where N: RefUnwindSafe,

§

impl<N> Send for XPathValue<N>
where N: Send,

§

impl<N> Sync for XPathValue<N>
where N: Sync,

§

impl<N> Unpin for XPathValue<N>
where N: Unpin,

§

impl<N> UnsafeUnpin for XPathValue<N>
where N: UnsafeUnpin,

§

impl<N> UnwindSafe for XPathValue<N>
where N: UnwindSafe,

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