Struct wasmi::MemoryInstance
[−]
[src]
pub struct MemoryInstance { /* fields omitted */ }
Runtime representation of a linear memory (or memory
for short).
A memory is a contiguous, mutable array of raw bytes. Wasm code can load and store values from/to a linear memory at any byte address. A trap occurs if an access is not within the bounds of the current memory size.
A memory is created with an initial size but can be grown dynamically. The growth can be limited by specifying maximum size. The size of a memory is always a integer multiple of a page size - 64KiB.
At the moment, wasm doesn't provide any way to shrink the memory.
Methods
impl MemoryInstance
[src]
fn alloc(
initial_pages: u32,
maximum_pages: Option<u32>
) -> Result<MemoryRef, Error>
[src]
initial_pages: u32,
maximum_pages: Option<u32>
) -> Result<MemoryRef, Error>
fn initial_pages(&self) -> u32
[src]
fn maximum_pages(&self) -> Option<u32>
[src]
fn size(&self) -> u32
[src]
Return linear memory size (in pages).
fn get(&self, offset: u32, size: usize) -> Result<Vec<u8>, Error>
[src]
Get data at given offset.
fn get_into(&self, offset: u32, target: &mut [u8]) -> Result<(), Error>
[src]
Write memory slice into another slice
fn set(&self, offset: u32, value: &[u8]) -> Result<(), Error>
[src]
Set data at given offset.
fn grow(&self, pages: u32) -> Result<u32, Error>
[src]
Increases the size of the linear memory by given number of pages. Returns previous memory size (in pages) if succeeds.
fn copy(
&self,
src_offset: usize,
dst_offset: usize,
len: usize
) -> Result<(), Error>
[src]
&self,
src_offset: usize,
dst_offset: usize,
len: usize
) -> Result<(), Error>
Copy memory region. Semantically equivalent to memmove
.
fn copy_nonoverlapping(
&self,
src_offset: usize,
dst_offset: usize,
len: usize
) -> Result<(), Error>
[src]
&self,
src_offset: usize,
dst_offset: usize,
len: usize
) -> Result<(), Error>
Copy memory region, non-overlapping version. Semantically equivalent to memcpy
,
but returns Error if source overlaping with destination.
fn clear(&self, offset: usize, new_val: u8, len: usize) -> Result<(), Error>
[src]
Clear memory region with a specified value. Semantically equivalent to memset
.
fn zero(&self, offset: usize, len: usize) -> Result<(), Error>
[src]
Zero memory region