Enum Item

Source
pub enum Item<N: Node> {
    Node(N),
    Function,
    Value(Rc<Value>),
}
Expand description

An Item in a Sequence. Can be a node, function or Value.

Functions are not yet implemented.

Variants§

§

Node(N)

A Node in the source document.

§

Function

Functions are not yet supported

§

Value(Rc<Value>)

A scalar value. These are in an Rc since they are frequently shared.

Implementations§

Source§

impl<N: Node> Item<N>

Source

pub fn to_xml(&self) -> String

Serialize as XML

Source

pub fn to_xml_with_options(&self, od: &OutputDefinition) -> String

Serialize as XML, with options

Source

pub fn to_json(&self) -> String

Serialize as JSON

Source

pub fn to_bool(&self) -> bool

Determine the effective boolean value of the item. See XPath 2.4.3.

Source

pub fn to_int(&self) -> Result<i64, Error>

Gives the integer value of the item, if possible.

Source

pub fn to_double(&self) -> f64

Gives the double value of the item. Returns NaN if the value cannot be converted to a double.

Source

pub fn name(&self) -> Rc<QualifiedName>

Gives the name of the item. Certain types of Nodes have names, such as element-type nodes. If the item does not have a name returns an empty string.

Source

pub fn compare(&self, other: &Item<N>, op: Operator) -> Result<bool, Error>

Compare two items.

Source

pub fn is_node(&self) -> bool

Is this item a node?

Source

pub fn is_element_node(&self) -> bool

Is this item an element-type node?

Source

pub fn add_attribute(&self, a: N) -> Result<(), Error>

Convenience method to set an attribute for a Node-type item. If the item is not an element-type node, then this method has no effect.

Source

pub fn item_type(&self) -> &'static str

Gives the type of the item.

Source

pub fn shallow_copy(&self) -> Result<Self, Error>

Make a shallow copy of an item. That is, the item is duplicated but not it’s content, including attributes.

Source

pub fn deep_copy(&self) -> Result<Self, Error>

Make a deep copy of an item.

Trait Implementations§

Source§

impl<N: Clone + Node> Clone for Item<N>

Source§

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

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<N: Node> Debug for Item<N>

Source§

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

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

impl<N: Node> Display for Item<N>

Source§

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

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

impl<N: Node> From<Item<N>> for Sequence<N>

Source§

fn from(i: Item<N>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

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

§

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

§

impl<N> !Send for Item<N>

§

impl<N> !Sync for Item<N>

§

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

§

impl<N> UnwindSafe for Item<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> 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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.
Source§

impl<T> ErasedDestructor for T
where T: 'static,