Trait Host

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

  1. accessing the advice provider,
  2. getting a library’s MAST forest,
  3. handling advice events (which internally mutates the advice provider), and
  4. handling debug and trace events.

Required Associated Types§

Required Methods§

Source

fn advice_provider(&self) -> &Self::AdviceProvider

Returns a reference to the advice provider.

Source

fn advice_provider_mut(&mut self) -> &mut Self::AdviceProvider

Returns a mutable reference to the advice provider.

Source

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§

Source

fn on_event( &mut self, _process: ProcessState<'_>, _event_id: u32, _err_ctx: &ErrorContext<'_, impl MastNodeExt>, ) -> Result<(), ExecutionError>

Handles the event emitted from the VM.

Source

fn on_debug( &mut self, _process: ProcessState<'_>, _options: &DebugOptions, ) -> Result<(), ExecutionError>

Handles the debug request from the VM.

Source

fn on_trace( &mut self, _process: ProcessState<'_>, _trace_id: u32, ) -> Result<(), ExecutionError>

Handles the trace emitted from the VM.

Source

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.

Implementations on Foreign Types§

Source§

impl<H> Host for &mut H
where H: Host,

Source§

type AdviceProvider = <H as Host>::AdviceProvider

Source§

fn advice_provider(&self) -> &Self::AdviceProvider

Source§

fn advice_provider_mut(&mut self) -> &mut Self::AdviceProvider

Source§

fn get_mast_forest(&self, node_digest: &RpoDigest) -> Option<Arc<MastForest>>

Source§

fn on_debug( &mut self, process: ProcessState<'_>, options: &DebugOptions, ) -> Result<(), ExecutionError>

Source§

fn on_event( &mut self, process: ProcessState<'_>, event_id: u32, err_ctx: &ErrorContext<'_, impl MastNodeExt>, ) -> Result<(), ExecutionError>

Source§

fn on_trace( &mut self, process: ProcessState<'_>, trace_id: u32, ) -> Result<(), ExecutionError>

Source§

fn on_assert_failed(&mut self, process: ProcessState<'_>, err_code: Felt)

Implementors§