pub trait Query<V> {
// Required methods
fn program(&self) -> &Program;
fn execute_with_context(
&self,
documents: &mut Documents,
context: &DynamicContext<'_>,
) -> Result<V>;
// Provided methods
fn static_context(&self) -> &StaticContext { ... }
fn dynamic_context_builder(
&self,
documents: &Documents,
) -> DynamicContextBuilder<'_> { ... }
fn map<T, F>(self, f: F) -> MapQuery<V, T, Self, F>
where Self: Sized,
F: Fn(V, &mut Documents, &DynamicContext<'_>) -> Result<T> + Clone { ... }
fn execute(
&self,
documents: &mut Documents,
item: impl Itemable,
) -> Result<V> { ... }
fn execute_build_context(
&self,
documents: &mut Documents,
build: impl FnOnce(&mut DynamicContextBuilder<'_>),
) -> Result<V> { ... }
}Expand description
A query that can be executed against an Itemable
It gives back a result of type V
Required Methods§
Sourcefn execute_with_context(
&self,
documents: &mut Documents,
context: &DynamicContext<'_>,
) -> Result<V>
fn execute_with_context( &self, documents: &mut Documents, context: &DynamicContext<'_>, ) -> Result<V>
Execute the query against a dynamic context
You can construct one using a DynamicContextBuilder
Provided Methods§
Sourcefn static_context(&self) -> &StaticContext
fn static_context(&self) -> &StaticContext
Get the static context for the query.
Sourcefn 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.
You can use this if you want to construct your own dynamic context
to use with execute_with_context.
Sourcefn 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.
You need to provide a function that takes the result of the query, the document, and the item, and returns a new result.
Sourcefn 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
Sourcefn 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.
This is useful if you want to build a dynamic context with specific settings (such as variables), and then execute a query against it.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.