dharitri_vm_executor/
instance.rs1use crate::{BreakpointValue, ExecutorError};
2
3pub struct CompilationOptions {
4 pub gas_limit: u64,
5 pub unmetered_locals: usize,
6 pub max_memory_grow: usize,
7 pub max_memory_grow_delta: usize,
8 pub opcode_trace: bool,
9 pub metering: bool,
10 pub runtime_breakpoints: bool,
11}
12
13pub type MemPtr = isize;
15
16pub type MemLength = isize;
18
19pub trait Instance {
20 fn call(&self, func_name: &str) -> Result<(), String>;
22
23 fn check_signatures(&self) -> bool;
25
26 fn has_function(&self, func_name: &str) -> bool;
28
29 fn get_exported_function_names(&self) -> Vec<String>;
31
32 fn set_points_limit(&self, limit: u64) -> Result<(), String>;
34
35 fn set_points_used(&self, points: u64) -> Result<(), String>;
37
38 fn get_points_used(&self) -> Result<u64, String>;
40
41 fn memory_length(&self) -> Result<u64, String>;
43
44 fn memory_ptr(&self) -> Result<*mut u8, String>;
46
47 fn memory_load(&self, mem_ptr: MemPtr, mem_length: MemLength) -> Result<&[u8], ExecutorError>;
49
50 fn memory_store(&self, mem_ptr: MemPtr, data: &[u8]) -> Result<(), ExecutorError>;
52
53 fn memory_grow(&self, by_num_pages: u32) -> Result<u32, ExecutorError>;
55
56 fn set_breakpoint_value(&self, value: BreakpointValue) -> Result<(), String>;
58
59 fn get_breakpoint_value(&self) -> Result<BreakpointValue, String>;
61
62 fn reset(&self) -> Result<(), String>;
64
65 fn cache(&self) -> Result<Vec<u8>, String>;
67}