pub struct TestHost<'a, R, BackingStore> {
pub rng_used: bool,
pub debug_events: Vec<EmittedDebugStatement>,
/* private fields */
}Expand description
A host which traps for any function call apart from report_error which it
prints to standard out and get_random that calls a random number
generator.
Fields§
§rng_used: boolA flag set to true if the RNG was used.
debug_events: Vec<EmittedDebugStatement>Debug statements in the order they were emitted.
Implementations§
Source§impl<'a, R: RngCore, BackingStore> TestHost<'a, R, BackingStore>
impl<'a, R: RngCore, BackingStore> TestHost<'a, R, BackingStore>
Sourcepub fn new(rng: R, state: InstanceState<'a, BackingStore>) -> Self
pub fn new(rng: R, state: InstanceState<'a, BackingStore>) -> Self
Create a new TestHost instance with the given RNG, set the flag to
unused, no debug events and use the provided instance state for
state-related host function calls.
Trait Implementations§
Source§impl<'a, R: RngCore, BackingStore: BackingStoreLoad> Host<ArtifactNamedImport> for TestHost<'a, R, BackingStore>
impl<'a, R: RngCore, BackingStore: BackingStoreLoad> Host<ArtifactNamedImport> for TestHost<'a, R, BackingStore>
type Interrupt = NoInterrupt
Source§fn tick_initial_memory(&mut self, _num_pages: u32) -> RunResult<()>
fn tick_initial_memory(&mut self, _num_pages: u32) -> RunResult<()>
Charge the given amount of energy for the initial memory.
The argument is the number of pages.
Source§fn call(
&mut self,
f: &ArtifactNamedImport,
memory: &mut [u8],
stack: &mut RuntimeStack,
) -> RunResult<Option<NoInterrupt>>
fn call( &mut self, f: &ArtifactNamedImport, memory: &mut [u8], stack: &mut RuntimeStack, ) -> RunResult<Option<NoInterrupt>>
Call the specified host function, giving it access to the current memory
and stack. The return value of
Ok(None) signifies that execution
succeeded and the machine should proceeed, the return value of
Ok(Some(i)) indicates that an interrupt was triggered by the host
function, and the return value of Err(_) signifies a trap, i.e., the
host function was called with illegal arguments. Read moreSource§fn track_call(&mut self) -> RunResult<()>
fn track_call(&mut self) -> RunResult<()>
Track a function call. This is called upon entry to a function. The
corresonding
track_return is called upon
return from a function. These two together can be used to track function
call stack depth. track_call can return an Err
to indicate that a call stack depth was exceeded. This will lead to
immediate termination of execution.Source§fn track_return(&mut self)
fn track_return(&mut self)
Called when a function returns. See documentation of
track_call for details.Auto Trait Implementations§
impl<'a, R, BackingStore> Freeze for TestHost<'a, R, BackingStore>
impl<'a, R, BackingStore> RefUnwindSafe for TestHost<'a, R, BackingStore>where
R: RefUnwindSafe,
BackingStore: RefUnwindSafe,
impl<'a, R, BackingStore> !Send for TestHost<'a, R, BackingStore>
impl<'a, R, BackingStore> Sync for TestHost<'a, R, BackingStore>
impl<'a, R, BackingStore> Unpin for TestHost<'a, R, BackingStore>
impl<'a, R, BackingStore> UnwindSafe for TestHost<'a, R, BackingStore>where
R: UnwindSafe,
BackingStore: UnwindSafe,
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
Mutably borrows from an owned value. Read more