[][src]Trait substrate_wasmtime::LinearMemory

pub unsafe trait LinearMemory {
    fn size(&self) -> u32;
fn grow(&self, delta: u32) -> Option<u32>;
fn as_ptr(&self) -> *mut u8; }

A linear memory. This trait provides an interface for raw memory buffers which are used by wasmtime, e.g. inside ['Memory']. Such buffers are in principle not thread safe. By implementing this trait together with MemoryCreator, one can supply wasmtime with custom allocated host managed memory.

Safety

The memory should be page aligned and a multiple of page size. To prevent possible silent overflows, the memory should be protected by a guard page. Additionally the safety concerns explained in ['Memory'], for accessing the memory apply here as well.

Note that this is a relatively new and experimental feature and it is recommended to be familiar with wasmtime runtime code to use it.

Required methods

fn size(&self) -> u32

Returns the number of allocated wasm pages.

fn grow(&self, delta: u32) -> Option<u32>

Grow memory by the specified amount of wasm pages.

Returns None if memory can't be grown by the specified amount of wasm pages.

fn as_ptr(&self) -> *mut u8

Return the allocated memory as a mutable pointer to u8.

Loading content...

Implementors

Loading content...