pub struct GenerateExecutor {
pub query: GenerateQuery,
}Expand description
Executes a parsed GenerateQuery over a set of SPARQL variable bindings.
§Example
use std::collections::HashMap;
use oxirs_arq::generate::{GenerateExecutor, Bindings, GenerateQuery, TemplateClause, GenerateLiteral};
let clause = TemplateClause {
prefix: Some("name=".to_string()),
expr: GenerateLiteral::Var("name".to_string()),
suffix: None,
};
let query = GenerateQuery::new(vec![clause], "?s foaf:name ?name .");
let exec = GenerateExecutor::new(query);
let mut row = HashMap::new();
row.insert("name".to_string(), "Alice".to_string());
let result = exec.evaluate_one(&row).unwrap();
assert_eq!(result.text, "name=Alice");Fields§
§query: GenerateQueryThe parsed GENERATE query to execute.
Implementations§
Source§impl GenerateExecutor
impl GenerateExecutor
Sourcepub fn new(query: GenerateQuery) -> Self
pub fn new(query: GenerateQuery) -> Self
Create a new executor for the given GenerateQuery.
Sourcepub fn evaluate_one(
&self,
bindings: &Bindings,
) -> Result<GenerateResult, GenerateError>
pub fn evaluate_one( &self, bindings: &Bindings, ) -> Result<GenerateResult, GenerateError>
Evaluate the GENERATE template against a single solution row.
Returns GenerateResult containing the concatenated text output and the
count of distinct bindings used during evaluation.
§Errors
Returns GenerateError::UnboundVariable if a Var reference in the
template is not present in bindings.
Sourcepub fn evaluate_all(
&self,
rows: &[Bindings],
) -> Result<Vec<GenerateResult>, GenerateError>
pub fn evaluate_all( &self, rows: &[Bindings], ) -> Result<Vec<GenerateResult>, GenerateError>
Evaluate the GENERATE template over multiple solution rows, collecting
one GenerateResult per row.
§Errors
Propagates any error returned by evaluate_one.
Sourcepub fn generate_text(
&self,
rows: &[Bindings],
separator: &str,
) -> Result<String, GenerateError>
pub fn generate_text( &self, rows: &[Bindings], separator: &str, ) -> Result<String, GenerateError>
Concatenate all generated texts (one per row) into a single String,
with separator between each adjacent pair.
§Errors
Propagates any error returned by evaluate_all.
Sourcepub fn eval_literal(
&self,
lit: &GenerateLiteral,
bindings: &Bindings,
) -> Result<String, GenerateError>
pub fn eval_literal( &self, lit: &GenerateLiteral, bindings: &Bindings, ) -> Result<String, GenerateError>
Evaluate a single GenerateLiteral given bindings.
This is the public-facing variant without variable tracking; it is useful for unit-testing individual literal expressions.
Auto Trait Implementations§
impl Freeze for GenerateExecutor
impl RefUnwindSafe for GenerateExecutor
impl Send for GenerateExecutor
impl Sync for GenerateExecutor
impl Unpin for GenerateExecutor
impl UnsafeUnpin for GenerateExecutor
impl UnwindSafe for GenerateExecutor
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<T> Fruit for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.