pub trait Executor: Sealed { }
Expand description

The main trait that allows query execution.

Note that compared to Client this trait has &mut self for query methods. This is because we need to support Executor for a transaction. To overcome this issue for Client you can either use inherent methods on the pool rather than this trait or just clone it (cloning Client is cheap):

do_query(&mut global_pool_reference.clone())?;

Due to limitations of the Rust type system, the query methods are part of the inherent implementation for dyn Executor, not in the trait itself. This should not be a problem in most cases.

This trait is sealed (no imlementation can be done outside of this crate), since we don’t want to expose too many implementation details for now.

Implementations

Execute a query and return a collection of results.

You will usually have to specify the return type for the query:

let greeting = pool.query::<String, _>("SELECT 'hello'", &());
// or
let greeting: Vec<String> = pool.query("SELECT 'hello'", &());

This method can be used with both static arguments, like a tuple of scalars, and with dynamic arguments edgedb_protocol::value::Value. Similarly, dynamically typed results are also supported.

Execute a query and return a single result.

You will usually have to specify the return type for the query:

let greeting = pool.query_single::<String, _>("SELECT 'hello'", &());
// or
let greeting: String = pool.query_single("SELECT 'hello'", &());

The query must return exactly one element. If the query returns more than one element, a ResultCardinalityMismatchError is raised. If the query returns an empty set, a NoDataError is raised.

This method can be used with both static arguments, like a tuple of scalars, and with dynamic arguments edgedb_protocol::value::Value. Similarly, dynamically typed results are also supported.

Execute a query and return the result as JSON.

Execute a query and return a single result as JSON.

The query must return exactly one element. If the query returns more than one element, a ResultCardinalityMismatchError is raised. If the query returns an empty set, a NoDataError is raised.

Execute one or more EdgeQL commands.

Note that if you want the results of query, use query() or query_single() instead.

Implementors