Struct Queries

Source
pub struct Queries<'a> { /* private fields */ }
Expand description

A collection of XPath queries

You can register xpath expressions with conversion functions to turn the results into Rust values.

Implementations§

Source§

impl<'a> Queries<'a>

Source

pub fn new(default_static_context_builder: StaticContextBuilder<'a>) -> Self

Construct a new collection of queries

Supply a default static context builder, which is used by default to construct a static context if none is supplied explicitly.

Source

pub fn one<V, F>(&self, s: &str, convert: F) -> Result<OneQuery<V, F>>
where F: Convert<V>,

Construct a query that expects a single item result.

This item is converted into a Rust value using supplied convert function.

This uses a default static context.

Source

pub fn one_with_context<V, F>( &self, s: &str, convert: F, static_context: StaticContext, ) -> Result<OneQuery<V, F>>
where F: Convert<V>,

Construct a query that expects a single item result.

This item is converted into a Rust value using supplied convert function.

You can supply a static context explicitly.

Source

pub fn one_recurse(&self, s: &str) -> Result<OneRecurseQuery>

Construct a query that expects a single item result.

This item is converted into a Rust value not using a convert function but through a recursive call that’s passed in during execution.

NOTE: recursion generally needs a stopping condition, but one_recurse expects one value always - unlike option_recurse and many_recurse which have the None or empty value. I think this means that one_recurse is not in fact useful.

Source

pub fn one_recurse_with_context( &self, s: &str, static_context: StaticContext, ) -> Result<OneRecurseQuery>

Construct a query that expects a single item result, with explicit static context.

Source

pub fn option<V, F>(&self, s: &str, convert: F) -> Result<OptionQuery<V, F>>
where F: Convert<V>,

Construct a query that expects an optional single item result.

This item is converted into a Rust value using supplied convert function.

Source

pub fn option_with_context<V, F>( &self, s: &str, convert: F, static_context: StaticContext, ) -> Result<OptionQuery<V, F>>
where F: Convert<V>,

Construct a query that expects an optional single item result with explicit static context.

Source

pub fn option_recurse(&self, s: &str) -> Result<OptionRecurseQuery>

Construct a recursive query that expects an optional single item result.

This item is converted into a Rust value not using a convert function but through a recursive call that’s passed in during execution.

Source

pub fn option_recurse_with_context( &self, s: &str, static_context: StaticContext, ) -> Result<OptionRecurseQuery>

Construct a recursive query that expects an optional single item result, with explicit static context.

Source

pub fn many<V, F>(&self, s: &str, convert: F) -> Result<ManyQuery<V, F>>
where F: Convert<V>,

Construct a query that expects many items as a result.

These items are converted into Rust values using supplied convert function.

Source

pub fn many_with_context<V, F>( &self, s: &str, convert: F, static_context: StaticContext, ) -> Result<ManyQuery<V, F>>
where F: Convert<V>,

Construct a query that expects many items as a result, with explicit static context.

Source

pub fn many_recurse(&self, s: &str) -> Result<ManyRecurseQuery>

Construct a query that expects many items as a result.

These items are converted into Rust values not using a convert function but through a recursive call that’s passed in during execution.

Source

pub fn many_recurse_with_context( &self, s: &str, static_context: StaticContext, ) -> Result<ManyRecurseQuery>

Construct a recursive query that expects many items as a result, with explicit static context.

Source

pub fn sequence(&self, s: &str) -> Result<SequenceQuery>

Construct a query that gets a [Sequence] as a result.

This is a low-level API that allows you to get the raw sequence without converting it into Rust values.

Source

pub fn sequence_with_context( &self, s: &str, static_context: StaticContext, ) -> Result<SequenceQuery>

Construct a query that gets a [Sequence] as a result, with explicit static context.

Trait Implementations§

Source§

impl<'a> Debug for Queries<'a>

Source§

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

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

impl<'a> Default for Queries<'a>

Source§

fn default() -> Queries<'a>

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

Auto Trait Implementations§

§

impl<'a> Freeze for Queries<'a>

§

impl<'a> RefUnwindSafe for Queries<'a>

§

impl<'a> Send for Queries<'a>

§

impl<'a> Sync for Queries<'a>

§

impl<'a> Unpin for Queries<'a>

§

impl<'a> UnwindSafe for Queries<'a>

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<'src, T> IntoMaybe<'src, T> for T
where T: 'src,

Source§

type Proj<U: 'src> = U

Source§

fn map_maybe<R>( self, _f: impl FnOnce(&'src T) -> &'src R, g: impl FnOnce(T) -> R, ) -> <T as IntoMaybe<'src, T>>::Proj<R>
where R: 'src,

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,

Source§

impl<T> MaybeSendSync for T