pub trait VirtManagerBackend: Send + 'static {
// Required methods
fn compile_from_bytes(
&mut self,
program: &[u8],
identifier: Option<&[u8]>,
) -> Result<ModuleId, ModuleError>;
fn lookup(&mut self, identifier: &[u8]) -> Result<ModuleId, ModuleError>;
fn instantiate(
&mut self,
module_id: ModuleId,
) -> Result<InstanceId, InstantiateError>;
fn prepare(
&mut self,
instance_id: InstanceId,
function: &[u8],
) -> Result<(), ExecError>;
fn run(
&mut self,
instance_id: InstanceId,
gas_left: i64,
a0: u64,
) -> Result<(ExecStatus, ExecBuffer), ExecError>;
fn destroy(&mut self, instance_id: InstanceId) -> Result<(), DestroyError>;
fn read_memory(
&mut self,
instance_id: InstanceId,
offset: u32,
dest: &mut [u8],
) -> Result<(), MemoryError>;
fn write_memory(
&mut self,
instance_id: InstanceId,
offset: u32,
src: &[u8],
) -> Result<(), MemoryError>;
}Expand description
The host-side operations driven by the virtualization host functions.
The concrete implementation lives outside this crate (see sc-virtualization) so that
sp-virtualization itself does not depend on a specific virtual machine backend.
Required Methods§
Sourcefn compile_from_bytes(
&mut self,
program: &[u8],
identifier: Option<&[u8]>,
) -> Result<ModuleId, ModuleError>
fn compile_from_bytes( &mut self, program: &[u8], identifier: Option<&[u8]>, ) -> Result<ModuleId, ModuleError>
Compile program into a new module.
If identifier is Some, the compiled module is retained in the per-extension cache
keyed by that opaque byte slice so a later lookup with the same bytes can reuse it.
Sourcefn lookup(&mut self, identifier: &[u8]) -> Result<ModuleId, ModuleError>
fn lookup(&mut self, identifier: &[u8]) -> Result<ModuleId, ModuleError>
Look up a module previously cached under identifier.
Returns ModuleError::NotCached if no module is cached under that key. The backend
never reads storage — identifier is an opaque byte slice as far as it is concerned.