pub trait Host {
type AdviceProvider: AdviceProvider;
// Required methods
fn advice_provider(&self) -> &Self::AdviceProvider;
fn advice_provider_mut(&mut self) -> &mut Self::AdviceProvider;
fn get_mast_forest(
&self,
node_digest: &RpoDigest,
) -> Option<Arc<MastForest>>;
// Provided methods
fn on_event(
&mut self,
_process: ProcessState<'_>,
_event_id: u32,
) -> Result<(), ExecutionError> { ... }
fn on_debug(
&mut self,
_process: ProcessState<'_>,
_options: &DebugOptions,
) -> Result<(), ExecutionError> { ... }
fn on_trace(
&mut self,
_process: ProcessState<'_>,
_trace_id: u32,
) -> Result<(), ExecutionError> { ... }
fn on_assert_failed(
&mut self,
process: ProcessState<'_>,
err_code: u32,
) -> ExecutionError { ... }
}Expand description
Defines an interface by which the VM can interact with the host.
There are four main categories of interactions between the VM and the host:
- accessing the advice provider,
- getting a library’s MAST forest,
- handling advice events (which internally mutates the advice provider), and
- handling debug and trace events.
Required Associated Types§
Required Methods§
Sourcefn advice_provider(&self) -> &Self::AdviceProvider
fn advice_provider(&self) -> &Self::AdviceProvider
Returns a reference to the advice provider.
Sourcefn advice_provider_mut(&mut self) -> &mut Self::AdviceProvider
fn advice_provider_mut(&mut self) -> &mut Self::AdviceProvider
Returns a mutable reference to the advice provider.
Sourcefn get_mast_forest(&self, node_digest: &RpoDigest) -> Option<Arc<MastForest>>
fn get_mast_forest(&self, node_digest: &RpoDigest) -> 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.
Provided Methods§
Sourcefn on_event(
&mut self,
_process: ProcessState<'_>,
_event_id: u32,
) -> Result<(), ExecutionError>
fn on_event( &mut self, _process: ProcessState<'_>, _event_id: u32, ) -> Result<(), ExecutionError>
Handles the event emitted from the VM.
Sourcefn on_debug(
&mut self,
_process: ProcessState<'_>,
_options: &DebugOptions,
) -> Result<(), ExecutionError>
fn on_debug( &mut self, _process: ProcessState<'_>, _options: &DebugOptions, ) -> Result<(), ExecutionError>
Handles the debug request from the VM.
Sourcefn on_trace(
&mut self,
_process: ProcessState<'_>,
_trace_id: u32,
) -> Result<(), ExecutionError>
fn on_trace( &mut self, _process: ProcessState<'_>, _trace_id: u32, ) -> Result<(), ExecutionError>
Handles the trace emitted from the VM.
Sourcefn on_assert_failed(
&mut self,
process: ProcessState<'_>,
err_code: u32,
) -> ExecutionError
fn on_assert_failed( &mut self, process: ProcessState<'_>, err_code: u32, ) -> ExecutionError
Handles the failure of the assertion instruction.