Skip to main content

ExprDataSource

Trait ExprDataSource 

Source
pub trait ExprDataSource<T = Value>: DataSource {
    // Required methods
    fn execute(
        &self,
        expr: &Expression<T>,
    ) -> impl Future<Output = Result<T, VantageError>> + Send;
    fn defer(&self, expr: Expression<T>) -> DeferredFn<T>
       where T: Clone + Send + Sync + 'static;

    // Provided method
    fn associate<R>(
        &self,
        expr: Expression<T>,
    ) -> AssociatedExpression<'_, Self, T, R>
       where Self: Sized { ... }
}
Expand description

DataSource that can also execute expressions.

Required Methods§

Source

fn execute( &self, expr: &Expression<T>, ) -> impl Future<Output = Result<T, VantageError>> + Send

Source

fn defer(&self, expr: Expression<T>) -> DeferredFn<T>
where T: Clone + Send + Sync + 'static,

Provided Methods§

Source

fn associate<R>( &self, expr: Expression<T>, ) -> AssociatedExpression<'_, Self, T, R>
where Self: Sized,

Create an associated expression with type-safe return type

§Examples
let count_expr = expr!("SELECT COUNT(*) FROM users");
let associated = ds.associate::<usize>(count_expr);
let result: usize = associated.get().await?;

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl ExprDataSource for MockTableSource

Source§

async fn execute(&self, expr: &Expression<Value>) -> Result<Value, VantageError>

Source§

fn defer(&self, expr: Expression<Value>) -> DeferredFn<Value>
where Value: Clone + Send + Sync + 'static,

Implementors§