dharitri_vm_executor/new_traits/
instance_state.rs

1use crate::{ExecutorError, MemLength, MemPtr};
2
3/// The interface through which VM hooks update the instance state.
4pub trait InstanceState {
5    /// Returns the number of points(gas) used by the given instance.
6    fn get_points_used(&mut self) -> Result<u64, ExecutorError>;
7
8    /// Sets the number of points(gas) for the given instance.
9    fn set_points_used(&mut self, points: u64) -> Result<(), ExecutorError>;
10
11    /// Copies data to new owned buffer.
12    fn memory_load_to_slice(&self, mem_ptr: MemPtr, dest: &mut [u8]) -> Result<(), ExecutorError>;
13
14    /// Copies data to new owned buffer.
15    fn memory_load_owned(
16        &self,
17        mem_ptr: MemPtr,
18        mem_length: MemLength,
19    ) -> Result<Vec<u8>, ExecutorError>;
20
21    /// Loads data to given slice. In certain cases
22    fn memory_store(&self, mem_ptr: MemPtr, data: &[u8]) -> Result<(), ExecutorError>;
23}