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:
- 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_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: &ProcessorState<'_>,
options: &DebugOptions,
) -> Result<(), Box<dyn Error + Sync + Send>>
fn on_debug( &mut self, process: &ProcessorState<'_>, options: &DebugOptions, ) -> Result<(), Box<dyn Error + Sync + Send>>
Handles the debug request from the VM.
Sourcefn on_trace(
&mut self,
process: &ProcessorState<'_>,
trace_id: u32,
) -> Result<(), Box<dyn Error + Sync + Send>>
fn on_trace( &mut self, process: &ProcessorState<'_>, trace_id: u32, ) -> Result<(), Box<dyn Error + Sync + Send>>
Handles the trace emitted from the VM.
Sourcefn resolve_event(&self, _event_id: EventId) -> Option<&EventName>
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.