Skip to main content

Run

Trait Run 

Source
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§

Source

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.

Source

fn execute( &self, program: &Self::Prepared, input: &[u8], ) -> impl Future<Output = Result<Vec<u8>, Self::Error>>

Execute a prepared program. Program’s format must match the format supported by this runner.

Provided Methods§

Source

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,

Run a program.

This is helper function for Run::prepare followed by Run::execute, with input encoding and output decoding.

Source

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().

Source

fn shutdown(&self) -> impl Future<Output = Result<(), Self::Error>>

Releases any claimed resources or network connections.

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.