Trait polkavm_common::utils::Access
source · pub trait Access<'a> {
type Error: Display;
// Required methods
fn get_reg(&self, reg: Reg) -> u32;
fn set_reg(&mut self, reg: Reg, value: u32);
fn read_memory_into_slice<'slice, T>(
&self,
address: u32,
buffer: &'slice mut T,
) -> Result<&'slice mut [u8], Self::Error>
where T: ?Sized + AsUninitSliceMut;
fn write_memory(
&mut self,
address: u32,
data: &[u8],
) -> Result<(), Self::Error>;
fn sbrk(&mut self, size: u32) -> Option<u32>;
fn heap_size(&self) -> u32;
fn program_counter(&self) -> Option<u32>;
fn native_program_counter(&self) -> Option<u64>;
fn gas_remaining(&self) -> Option<Gas>;
fn consume_gas(&mut self, gas: u64);
// Provided method
fn read_memory_into_vec(
&self,
address: u32,
length: u32,
) -> Result<Vec<u8>, Self::Error> { ... }
}
Required Associated Types§
Required Methods§
fn get_reg(&self, reg: Reg) -> u32
fn set_reg(&mut self, reg: Reg, value: u32)
fn read_memory_into_slice<'slice, T>(
&self,
address: u32,
buffer: &'slice mut T,
) -> Result<&'slice mut [u8], Self::Error>where
T: ?Sized + AsUninitSliceMut,
fn write_memory(&mut self, address: u32, data: &[u8]) -> Result<(), Self::Error>
fn sbrk(&mut self, size: u32) -> Option<u32>
fn program_counter(&self) -> Option<u32>
fn native_program_counter(&self) -> Option<u64>
sourcefn gas_remaining(&self) -> Option<Gas>
fn gas_remaining(&self) -> Option<Gas>
Gets the amount of gas remaining, or None
if gas metering is not enabled for this instance.
Note that this being zero doesn’t necessarily mean that the execution ran out of gas, if the program ended up consuming exactly the amount of gas that it was provided with!
fn consume_gas(&mut self, gas: u64)
Provided Methods§
Object Safety§
This trait is not object safe.