[][src]Trait sp_wasm_interface::Sandbox

pub trait Sandbox {
    pub fn memory_get(
        &mut self,
        memory_id: MemoryId,
        offset: WordSize,
        buf_ptr: Pointer<u8>,
        buf_len: WordSize
    ) -> Result<u32>;
pub fn memory_set(
        &mut self,
        memory_id: MemoryId,
        offset: WordSize,
        val_ptr: Pointer<u8>,
        val_len: WordSize
    ) -> Result<u32>;
pub fn memory_teardown(&mut self, memory_id: MemoryId) -> Result<()>;
pub fn memory_new(&mut self, initial: u32, maximum: u32) -> Result<MemoryId>;
pub fn invoke(
        &mut self,
        instance_id: u32,
        export_name: &str,
        args: &[u8],
        return_val: Pointer<u8>,
        return_val_len: WordSize,
        state: u32
    ) -> Result<u32>;
pub fn instance_teardown(&mut self, instance_id: u32) -> Result<()>;
pub fn instance_new(
        &mut self,
        dispatch_thunk_id: u32,
        wasm: &[u8],
        raw_env_def: &[u8],
        state: u32
    ) -> Result<u32>;
pub fn get_global_val(
        &self,
        instance_idx: u32,
        name: &str
    ) -> Result<Option<Value>>; }

Something that provides access to the sandbox.

Required methods

pub fn memory_get(
    &mut self,
    memory_id: MemoryId,
    offset: WordSize,
    buf_ptr: Pointer<u8>,
    buf_len: WordSize
) -> Result<u32>

Get sandbox memory from the memory_id instance at offset into the given buffer.

pub fn memory_set(
    &mut self,
    memory_id: MemoryId,
    offset: WordSize,
    val_ptr: Pointer<u8>,
    val_len: WordSize
) -> Result<u32>

Set sandbox memory from the given value.

pub fn memory_teardown(&mut self, memory_id: MemoryId) -> Result<()>

Delete a memory instance.

pub fn memory_new(&mut self, initial: u32, maximum: u32) -> Result<MemoryId>

Create a new memory instance with the given initial size and the maximum size. The size is given in wasm pages.

pub fn invoke(
    &mut self,
    instance_id: u32,
    export_name: &str,
    args: &[u8],
    return_val: Pointer<u8>,
    return_val_len: WordSize,
    state: u32
) -> Result<u32>

Invoke an exported function by a name.

pub fn instance_teardown(&mut self, instance_id: u32) -> Result<()>

Delete a sandbox instance.

pub fn instance_new(
    &mut self,
    dispatch_thunk_id: u32,
    wasm: &[u8],
    raw_env_def: &[u8],
    state: u32
) -> Result<u32>

Create a new sandbox instance.

pub fn get_global_val(
    &self,
    instance_idx: u32,
    name: &str
) -> Result<Option<Value>>

Get the value from a global with the given name. The sandbox is determined by the given instance_idx instance.

Returns Some(_) when the requested global variable could be found.

Loading content...

Implementors

Loading content...