pub trait BaseHost {
// Required methods
fn get_mast_forest(&self, node_digest: &Word) -> Option<Arc<MastForest>>;
fn get_label_and_source_file(
&self,
location: &Location,
) -> (SourceSpan, Option<Arc<SourceFile>>);
// Provided methods
fn on_debug(
&mut self,
process: &mut ProcessState<'_>,
options: &DebugOptions,
) -> Result<(), ExecutionError> { ... }
fn on_trace(
&mut self,
process: &mut ProcessState<'_>,
trace_id: u32,
) -> Result<(), ExecutionError> { ... }
fn on_assert_failed(&mut self, _process: &ProcessState<'_>, _err_code: Felt) { ... }
}
Expand description
Defines the common interface between SyncHost and AsyncHost, by which the VM can interact with the host.
There are three main categories of interactions between the VM and the host:
- getting a library’s MAST forest,
- handling VM events (which can mutate the process’ advice provider), and
- handling debug and trace events.
Required Methods§
Sourcefn get_mast_forest(&self, node_digest: &Word) -> Option<Arc<MastForest>>
fn get_mast_forest(&self, node_digest: &Word) -> Option<Arc<MastForest>>
Returns MAST forest corresponding to the specified digest, or None if the MAST forest for this digest could not be found in this host.
Sourcefn get_label_and_source_file(
&self,
location: &Location,
) -> (SourceSpan, Option<Arc<SourceFile>>)
fn get_label_and_source_file( &self, location: &Location, ) -> (SourceSpan, Option<Arc<SourceFile>>)
Returns the SourceSpan
and optional SourceFile
for the provided location.
Provided Methods§
Sourcefn on_debug(
&mut self,
process: &mut ProcessState<'_>,
options: &DebugOptions,
) -> Result<(), ExecutionError>
fn on_debug( &mut self, process: &mut ProcessState<'_>, options: &DebugOptions, ) -> Result<(), ExecutionError>
Handles the debug request from the VM.
Sourcefn on_trace(
&mut self,
process: &mut ProcessState<'_>,
trace_id: u32,
) -> Result<(), ExecutionError>
fn on_trace( &mut self, process: &mut ProcessState<'_>, trace_id: u32, ) -> Result<(), ExecutionError>
Handles the trace emitted from the VM.
Sourcefn on_assert_failed(&mut self, _process: &ProcessState<'_>, _err_code: Felt)
fn on_assert_failed(&mut self, _process: &ProcessState<'_>, _err_code: Felt)
Handles the failure of the assertion instruction.