pub struct Instance(_);
Expand description
An instance of a module.
Implementations
sourceimpl Instance
impl Instance
sourcepub unsafe fn checked_memory_slice(
&self,
offset: u32,
size: usize
) -> Result<&[u8], Error>
pub unsafe fn checked_memory_slice(
&self,
offset: u32,
size: usize
) -> Result<&[u8], Error>
Obtain a read-only slice of underlying memory.
Safety
These slices turn invalid if the memory is resized (i.e. via the WebAssembly memory.grow
instruction)
sourcepub unsafe fn checked_memory_slice_mut(
&mut self,
offset: u32,
size: usize
) -> Result<&mut [u8], Error>
pub unsafe fn checked_memory_slice_mut(
&mut self,
offset: u32,
size: usize
) -> Result<&mut [u8], Error>
Obtain a mutable slice of underlying memory.
Safety
These slices turn invalid if the memory is resized (i.e. via the WebAssembly memory.grow
instruction)
sourcepub fn memory_size(&self) -> usize
pub fn memory_size(&self) -> usize
Returns the current memory size, in bytes.
sourcepub fn memory_get(&self, offset: u32, target: &mut [u8]) -> Result<(), Error>
pub fn memory_get(&self, offset: u32, target: &mut [u8]) -> Result<(), Error>
Copies memory from offset
to target
, for the length of target.len()
.
sourcepub fn memory_set(&mut self, offset: u32, source: &[u8]) -> Result<(), Error>
pub fn memory_set(&mut self, offset: u32, source: &[u8]) -> Result<(), Error>
Copies memory from source
to offset
, for the length of source.len()
.
sourcepub fn find_exported_function_index(&self, name: &str) -> Option<u32>
pub fn find_exported_function_index(&self, name: &str) -> Option<u32>
Find index of exported function by name.
sourcepub unsafe fn unsafe_execute(
&mut self,
func_idx: u32,
args: &[Value]
) -> ExecutionResult
pub unsafe fn unsafe_execute(
&mut self,
func_idx: u32,
args: &[Value]
) -> ExecutionResult
Unsafe execution of a given function index func_idx
with the given values args
.
An invalid index, invalid inputs, or invalid depth can cause undefined behaviour.
Safety
This function expects a valid func_idx
and appropriate number of args
.
sourcepub fn execute(
&mut self,
name: &str,
args: &[TypedValue]
) -> Result<Option<TypedValue>, Error>
pub fn execute(
&mut self,
name: &str,
args: &[TypedValue]
) -> Result<Option<TypedValue>, Error>
Execute a given function of name
with the given values args
.
An error is returned if the function can not be found, inappropriate number of arguments are passed, or the supplied types are mismatching.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Instance
impl !Send for Instance
impl !Sync for Instance
impl Unpin for Instance
impl UnwindSafe for Instance
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more