pub struct DefaultHost<D = DefaultDebugHandler, S = DefaultSourceManager>where
D: DebugHandler,
S: SourceManager,{ /* private fields */ }Expand description
A default SyncHost implementation that provides the essential functionality required by the VM.
Implementations§
Source§impl<D, S> DefaultHost<D, S>where
D: DebugHandler,
S: SourceManager,
impl<D, S> DefaultHost<D, S>where
D: DebugHandler,
S: SourceManager,
Sourcepub fn with_source_manager<O>(self, source_manager: Arc<O>) -> DefaultHost<D, O>where
O: SourceManager,
pub fn with_source_manager<O>(self, source_manager: Arc<O>) -> DefaultHost<D, O>where
O: SourceManager,
Use the given source manager implementation instead of the default one
[DefaultSourceManager].
Sourcepub fn load_library(
&mut self,
library: impl Into<HostLibrary>,
) -> Result<(), ExecutionError>
pub fn load_library( &mut self, library: impl Into<HostLibrary>, ) -> Result<(), ExecutionError>
Loads a HostLibrary containing a [MastForest] with its list of event handlers.
Sourcepub fn with_library(
self,
library: impl Into<HostLibrary>,
) -> Result<DefaultHost<D, S>, ExecutionError>
pub fn with_library( self, library: impl Into<HostLibrary>, ) -> Result<DefaultHost<D, S>, ExecutionError>
Adds a HostLibrary containing a [MastForest] with its list of event handlers.
to the host.
Sourcepub fn register_handler(
&mut self,
event: EventName,
handler: Arc<dyn EventHandler>,
) -> Result<(), ExecutionError>
pub fn register_handler( &mut self, event: EventName, handler: Arc<dyn EventHandler>, ) -> Result<(), ExecutionError>
Registers a single EventHandler into this host.
The handler can be either a closure or a free function with signature
fn(&mut ProcessorState) -> Result<(), EventHandler>
Sourcepub fn unregister_handler(&mut self, id: EventId) -> bool
pub fn unregister_handler(&mut self, id: EventId) -> bool
Un-registers a handler with the given id, returning a flag indicating whether a handler was previously registered with this id.
Sourcepub fn replace_handler(
&mut self,
event: EventName,
handler: Arc<dyn EventHandler>,
) -> bool
pub fn replace_handler( &mut self, event: EventName, handler: Arc<dyn EventHandler>, ) -> bool
Replaces a handler with the given event, returning a flag indicating whether a handler was previously registered with this event ID.
Sourcepub fn with_debug_handler<H>(self, handler: H) -> DefaultHost<H, S>where
H: DebugHandler,
pub fn with_debug_handler<H>(self, handler: H) -> DefaultHost<H, S>where
H: DebugHandler,
Replace the current DebugHandler with a custom one.
Sourcepub fn debug_handler(&self) -> &D
pub fn debug_handler(&self) -> &D
Returns a reference to the DebugHandler, useful for recovering debug information
emitted during a program execution.
Trait Implementations§
Source§impl<D, S> BaseHost for DefaultHost<D, S>where
D: DebugHandler,
S: SourceManager,
impl<D, S> BaseHost for DefaultHost<D, S>where
D: DebugHandler,
S: SourceManager,
Source§fn 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>>)
SourceSpan] and optional [SourceFile] for the provided location.Source§fn 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>>
Source§fn 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>>
Source§fn resolve_event(&self, event_id: EventId) -> Option<&EventName>
fn resolve_event(&self, event_id: EventId) -> Option<&EventName>
Source§impl<D, S> Debug for DefaultHost<D, S>
impl<D, S> Debug for DefaultHost<D, S>
Source§impl Default for DefaultHost
impl Default for DefaultHost
Source§fn default() -> DefaultHost
fn default() -> DefaultHost
Source§impl<D, S> SyncHost for DefaultHost<D, S>where
D: DebugHandler,
S: SourceManager,
impl<D, S> SyncHost for DefaultHost<D, S>where
D: DebugHandler,
S: SourceManager,
Auto Trait Implementations§
impl<D, S> Freeze for DefaultHost<D, S>where
D: Freeze,
impl<D = DefaultDebugHandler, S = DefaultSourceManager> !RefUnwindSafe for DefaultHost<D, S>
impl<D, S> Send for DefaultHost<D, S>
impl<D, S> Sync for DefaultHost<D, S>
impl<D, S> Unpin for DefaultHost<D, S>where
D: Unpin,
impl<D, S> UnsafeUnpin for DefaultHost<D, S>where
D: UnsafeUnpin,
impl<D = DefaultDebugHandler, S = DefaultSourceManager> !UnwindSafe for DefaultHost<D, S>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Host for Twhere
T: SyncHost,
impl<T> Host for Twhere
T: SyncHost,
Source§fn get_mast_forest(
&self,
node_digest: &Word,
) -> impl FutureMaybeSend<Option<Arc<MastForest>>>
fn get_mast_forest( &self, node_digest: &Word, ) -> impl FutureMaybeSend<Option<Arc<MastForest>>>
Source§fn on_event(
&mut self,
process: &ProcessorState<'_>,
) -> impl FutureMaybeSend<Result<Vec<AdviceMutation>, Box<dyn Error + Sync + Send>>>
fn on_event( &mut self, process: &ProcessorState<'_>, ) -> impl FutureMaybeSend<Result<Vec<AdviceMutation>, Box<dyn Error + Sync + Send>>>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<D> OwoColorize for D
impl<D> OwoColorize for D
§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg] or
a color-specific method, such as [OwoColorize::green], Read more§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg] or
a color-specific method, such as [OwoColorize::on_yellow], Read more