Enum xrust::item::Item

source ·
pub enum Item<N: Node> {
    Node(N),
    Function,
    Value(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(Value)

A scalar value

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) -> 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_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> RefUnwindSafe for Item<N>
where N: RefUnwindSafe,

§

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

§

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

§

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

§

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§

default 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>,

§

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

§

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.