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,
_err_ctx: &ErrorContext<'_, impl MastNodeExt>,
) -> 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: Felt) { ... }
}
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,
_err_ctx: &ErrorContext<'_, impl MastNodeExt>,
) -> Result<(), ExecutionError>
fn on_event( &mut self, _process: ProcessState<'_>, _event_id: u32, _err_ctx: &ErrorContext<'_, impl MastNodeExt>, ) -> 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: Felt)
fn on_assert_failed(&mut self, _process: ProcessState<'_>, _err_code: Felt)
Handles the failure of the assertion instruction.
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.