pub struct OptionQuery<V, F>where
F: Convert<V>,{ /* private fields */ }Expand description
This is a query that expects an optional single item.
Construct this using [‘Queries::option’].
If the sequence is empty, None is returned. If it contains more than one
item, an error is returned.
The result is converted into a Rust value using the convert function
when constructing this query.
This is useful if you expect an optional single item to be returned from an XPath query.
Implementations§
Source§impl<V, F> OptionQuery<V, F>where
F: Convert<V>,
impl<V, F> OptionQuery<V, F>where
F: Convert<V>,
Sourcepub fn execute_with_context(
&self,
document: &mut Documents,
context: &DynamicContext<'_>,
) -> Result<Option<V>>
pub fn execute_with_context( &self, document: &mut Documents, context: &DynamicContext<'_>, ) -> Result<Option<V>>
Execute the query against an itemable, with explicit dynamic context.
Trait Implementations§
Source§impl<V: Clone, F> Clone for OptionQuery<V, F>
impl<V: Clone, F> Clone for OptionQuery<V, F>
Source§fn clone(&self) -> OptionQuery<V, F>
fn clone(&self) -> OptionQuery<V, F>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<V: Debug, F> Debug for OptionQuery<V, F>
impl<V: Debug, F> Debug for OptionQuery<V, F>
Source§impl<V, F> Query<Option<V>> for OptionQuery<V, F>where
F: Convert<V>,
impl<V, F> Query<Option<V>> for OptionQuery<V, F>where
F: Convert<V>,
Source§fn execute_with_context(
&self,
document: &mut Documents,
context: &DynamicContext<'_>,
) -> Result<Option<V>>
fn execute_with_context( &self, document: &mut Documents, context: &DynamicContext<'_>, ) -> Result<Option<V>>
Execute the query against a dynamic context Read more
Source§fn static_context(&self) -> &StaticContext
fn static_context(&self) -> &StaticContext
Get the static context for the query.
Source§fn dynamic_context_builder(
&self,
documents: &Documents,
) -> DynamicContextBuilder<'_>
fn dynamic_context_builder( &self, documents: &Documents, ) -> DynamicContextBuilder<'_>
Get a dynamic context builder for the query, configured with the
query’s static context and the document’s documents. Read more
Source§fn map<T, F>(self, f: F) -> MapQuery<V, T, Self, F>
fn map<T, F>(self, f: F) -> MapQuery<V, T, Self, F>
Map the the result of the query to a different type. Read more
Source§fn execute(&self, documents: &mut Documents, item: impl Itemable) -> Result<V>
fn execute(&self, documents: &mut Documents, item: impl Itemable) -> Result<V>
Excute the query against an itemable
Source§fn execute_build_context(
&self,
documents: &mut Documents,
build: impl FnOnce(&mut DynamicContextBuilder<'_>),
) -> Result<V>
fn execute_build_context( &self, documents: &mut Documents, build: impl FnOnce(&mut DynamicContextBuilder<'_>), ) -> Result<V>
Execute a query with a specific dynamic context. Read more
Auto Trait Implementations§
impl<V, F> Freeze for OptionQuery<V, F>where
F: Freeze,
impl<V, F> !RefUnwindSafe for OptionQuery<V, F>
impl<V, F> !Send for OptionQuery<V, F>
impl<V, F> !Sync for OptionQuery<V, F>
impl<V, F> Unpin for OptionQuery<V, F>
impl<V, F> !UnwindSafe for OptionQuery<V, F>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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