pub trait RunSync {
type Error: Debug;
type Prepared;
// Required methods
fn prepare_sync(
&mut self,
program: Program,
) -> Result<Self::Prepared, Self::Error>;
fn execute_sync(
&mut self,
program: &Self::Prepared,
input: &[u8],
) -> Result<Vec<u8>, Self::Error>;
// Provided methods
fn run_sync<I, O>(
&mut self,
program: &TypedProgram<I, O>,
input: &I,
) -> Result<Result<O>, Self::Error>
where I: Encode,
O: Decode { ... }
fn get_interface_sync(&mut self) -> Result<String, Self::Error> { ... }
fn shutdown_sync(&mut self) -> Result<(), Self::Error> { ... }
}Expand description
Synchronous version of the Run trait for runners that don’t block the process.
This trait should only be implemented for runners that:
- Execute entirely in-memory (like the interpreter)
- Use internal thread pools for blocking operations (like DuckDB)
Do NOT implement this for runners that perform actual async I/O operations (like network database connections).
Methods take &mut self since synchronous operations may need to mutate
internal state (like database connections).
Required Associated Types§
Required Methods§
Sourcefn prepare_sync(
&mut self,
program: Program,
) -> Result<Self::Prepared, Self::Error>
fn prepare_sync( &mut self, program: Program, ) -> Result<Self::Prepared, Self::Error>
Prepares a program for execution and returns a handle, which can be used with RunSync::execute_sync.
If the program is invalid, error is returned either now or later by RunSync::execute_sync.
When the handle is returned, the program might not be fully prepared yet, so first execution of the program might take longer then subsequent RunSync::execute_sync calls.
Provided Methods§
Sourcefn run_sync<I, O>(
&mut self,
program: &TypedProgram<I, O>,
input: &I,
) -> Result<Result<O>, Self::Error>
fn run_sync<I, O>( &mut self, program: &TypedProgram<I, O>, input: &I, ) -> Result<Result<O>, Self::Error>
Run a program.
This is helper function for RunSync::prepare_sync followed by RunSync::execute_sync, with input encoding and output decoding.
Sourcefn get_interface_sync(&mut self) -> Result<String, Self::Error>
fn get_interface_sync(&mut self) -> 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 DuckDB runner can provide sql::read_table().
Sourcefn shutdown_sync(&mut self) -> Result<(), Self::Error>
fn shutdown_sync(&mut self) -> Result<(), Self::Error>
Releases any claimed resources.
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.