pub trait Run {
type Error: Debug;
type Prepared;
// Required methods
fn prepare(
&self,
program: Program,
) -> impl Future<Output = Result<Self::Prepared, Self::Error>>;
fn execute(
&self,
program: &Self::Prepared,
input: &[u8],
) -> impl Future<Output = Result<Vec<u8>, Self::Error>>;
// Provided methods
fn run<I, O>(
&self,
program: &TypedProgram<I, O>,
input: &I,
) -> impl Future<Output = Result<Result<O, Error>, Self::Error>>
where I: Encode,
O: Decode { ... }
fn get_interface(&self) -> impl Future<Output = Result<String, Self::Error>> { ... }
fn shutdown(&self) -> impl Future<Output = Result<(), Self::Error>> { ... }
}Expand description
Ability to execute a lutra program.
Required Associated Types§
Required Methods§
Sourcefn prepare(
&self,
program: Program,
) -> impl Future<Output = Result<Self::Prepared, Self::Error>>
fn prepare( &self, program: Program, ) -> impl Future<Output = Result<Self::Prepared, Self::Error>>
Prepares a program for execution and returns a handle, which can be used with Run::execute.
If the program is invalid, error is returned either now or later by Run::execute.
When the handle is returned, the program might not be fully prepared yet, so first execution of the program might take longer then subsequent Run::execute calls.
Provided Methods§
Sourcefn run<I, O>(
&self,
program: &TypedProgram<I, O>,
input: &I,
) -> impl Future<Output = Result<Result<O, Error>, Self::Error>>
fn run<I, O>( &self, program: &TypedProgram<I, O>, input: &I, ) -> impl Future<Output = Result<Result<O, Error>, Self::Error>>
Run a program.
This is helper function for Run::prepare followed by Run::execute, with input encoding and output decoding.
Sourcefn get_interface(&self) -> impl Future<Output = Result<String, Self::Error>>
fn get_interface(&self) -> impl Future<Output = Result<String, Self::Error>>
Return static interface of this runner as Lutra source code.
Runners can provide implementations for functions that are not part of standard library. This function returns definitions of these functions as Lutra source code.
For example: interpreter can provide fs::read_parquet()
and PostgreSQL runner can provide sql::read_table().
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§
Source§impl<C> Run for RunnerAsync<C>where
C: GenericClient,
Available on crate feature tokio-postgres only.
impl<C> Run for RunnerAsync<C>where
C: GenericClient,
tokio-postgres only.