Trait Executor

Source
pub trait Executor {
    type Value: Send;
    type Result: Send;
    type Error: Display;

    // Required method
    fn execute(
        &self,
        values: Vec<Self::Value>,
    ) -> impl Future<Output = Result<Vec<Self::Result>, Self::Error>> + Send;
}
Expand description

A trait for using a batch of values to execute some operation, such as a bulk insertion in a datastore. An Executor will be given an array of values and should handle each value, then return a result for each. Implementing Executor will allow operations to be batched by using a BatchExecutor. See the BatchExecutor docs for details about batching and error semantics.

Required Associated Types§

Source

type Value: Send

The input value provided by the caller to do something.

Source

type Result: Send

The output value returned by the executor back to the caller for each input value.

Source

type Error: Display

The error indicating that executing a batch failed.

Required Methods§

Source

fn execute( &self, values: Vec<Self::Value>, ) -> impl Future<Output = Result<Vec<Self::Result>, Self::Error>> + Send

Execute the operation for each value in the batch, returning a result for each value. If Ok(_) is returned, a Vec should be returned, where each element corresponds to the result of the input value at the same index. If no element is present for a given input value, then the caller will not receive a value. If Err(_) is returned, then the caller waiting on the batch will receive an ExecuteError::ExecutorError.

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.

Implementors§