dharitri_vm_executor/new_traits/
instance_new.rs

1use crate::{BreakpointValue, ExecutorError, VMHooksEarlyExit};
2
3pub enum InstanceCallResult {
4    Ok,
5    FunctionNotFound,
6    RuntimeError(ExecutorError),
7    VMHooksEarlyExit(VMHooksEarlyExit),
8    Breakpoint(BreakpointValue),
9}
10
11/// The new instance trait, only used for configuring & calling the wasmer instance.
12pub trait Instance {
13    /// Calls an exported function of a WebAssembly instance by `name`.
14    fn call(&mut self, func_name: &str, points_limit: u64) -> InstanceCallResult;
15
16    /// Checks that all public module functions (SC endpoints) have no arguments or results.
17    fn check_signatures(&self) -> bool;
18
19    /// Checks whether SC has an endpoint with given name.
20    fn has_function(&self, func_name: &str) -> bool;
21
22    /// Required to be able to extract all SC endpoint names.
23    fn get_exported_function_names(&self) -> Vec<String>;
24
25    /// Returns the number of points(gas) used by the given instance.
26    fn get_points_used(&mut self) -> Result<u64, ExecutorError>;
27
28    /// Resets an instance, cleaning memories and globals.
29    fn reset(&self) -> Result<(), ExecutorError>;
30
31    /// Caches an instance.
32    fn cache(&self) -> Result<Vec<u8>, ExecutorError>;
33}