Skip to main content

BaseHost

Trait BaseHost 

Source
pub trait BaseHost {
    // Required method
    fn get_label_and_source_file(
        &self,
        location: &Location,
    ) -> (SourceSpan, Option<Arc<SourceFile>>);

    // Provided methods
    fn on_debug(
        &mut self,
        process: &ProcessorState<'_>,
        options: &DebugOptions,
    ) -> Result<(), Box<dyn Error + Sync + Send>> { ... }
    fn on_trace(
        &mut self,
        process: &ProcessorState<'_>,
        trace_id: u32,
    ) -> Result<(), Box<dyn Error + Sync + Send>> { ... }
    fn resolve_event(&self, _event_id: EventId) -> Option<&EventName> { ... }
}
Expand description

Defines the host functionality shared by both sync and async execution.

There are three main categories of interactions between the VM and the host:

  1. getting a library’s MAST forest,
  2. handling VM events (which can mutate the process’ advice provider), and
  3. handling debug and trace events.

Required Methods§

Source

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§

Source

fn on_debug( &mut self, process: &ProcessorState<'_>, options: &DebugOptions, ) -> Result<(), Box<dyn Error + Sync + Send>>

Handles the debug request from the VM.

Source

fn on_trace( &mut self, process: &ProcessorState<'_>, trace_id: u32, ) -> Result<(), Box<dyn Error + Sync + Send>>

Handles the trace emitted from the VM.

Source

fn resolve_event(&self, _event_id: EventId) -> Option<&EventName>

Returns the [EventName] registered for the provided [EventId], if any.

Hosts that maintain an event registry can override this method to surface human-readable names for diagnostics. The default implementation returns None.

Implementors§

Source§

impl<D, S> BaseHost for DefaultHost<D, S>
where D: DebugHandler, S: SourceManager,

Source§

impl<S> BaseHost for TestHost<S>
where S: SourceManagerSync,