Trait edgedb_client::Executor[][src]

pub trait Executor: Sealed { }
Expand description

Main trait that allows executing queries

Note comparing 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 pool rather than this trait or just clone it (cloning Client is cheap):

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

Note: due to limitations of Rust type system, the query methods are part of inherent implementation for dyn Executor itself, 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 much implementation details for now.

Implementations

Execute a query returning a list of arguments

Most of the times you have to specify 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 both with static arguments, like a tuple of scalars. And with dynamic arguments edgedb_protocol::value::Value. Similarly dynamically typed results are also suported.

Execute a query returning a single result

Most of the times you have to specify return type for the query:

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

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

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

Execute a query returning result as a JSON

Run a singleton-returning query and return its element in JSON

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

Execute an EdgeQL command (or commands).

Note: If the results of query are desired, query() or query_single() should be used instead.

Implementors