pub trait Memory<Context> {
type GrowError: Debug;
// Required methods
fn grow(
&self,
ctx: &mut Context,
pages: WasmPagesAmount,
) -> Result<(), Self::GrowError>;
fn size(&self, ctx: &Context) -> WasmPagesAmount;
fn write(
&self,
ctx: &mut Context,
offset: u32,
buffer: &[u8],
) -> Result<(), MemoryError>;
fn read(
&self,
ctx: &Context,
offset: u32,
buffer: &mut [u8],
) -> Result<(), MemoryError>;
unsafe fn get_buffer_host_addr_unsafe(&self, ctx: &Context) -> HostPointer;
// Provided method
fn get_buffer_host_addr(&self, ctx: &Context) -> Option<HostPointer> { ... }
}
Expand description
Backend wasm memory interface.
Required Associated Types§
Required Methods§
sourcefn grow(
&self,
ctx: &mut Context,
pages: WasmPagesAmount,
) -> Result<(), Self::GrowError>
fn grow( &self, ctx: &mut Context, pages: WasmPagesAmount, ) -> Result<(), Self::GrowError>
Grow memory by number of pages.
sourcefn size(&self, ctx: &Context) -> WasmPagesAmount
fn size(&self, ctx: &Context) -> WasmPagesAmount
Return current size of the memory.
sourcefn write(
&self,
ctx: &mut Context,
offset: u32,
buffer: &[u8],
) -> Result<(), MemoryError>
fn write( &self, ctx: &mut Context, offset: u32, buffer: &[u8], ) -> Result<(), MemoryError>
Set memory region at specific pointer.
sourcefn read(
&self,
ctx: &Context,
offset: u32,
buffer: &mut [u8],
) -> Result<(), MemoryError>
fn read( &self, ctx: &Context, offset: u32, buffer: &mut [u8], ) -> Result<(), MemoryError>
Reads memory contents at the given offset into a buffer.
sourceunsafe fn get_buffer_host_addr_unsafe(&self, ctx: &Context) -> HostPointer
unsafe fn get_buffer_host_addr_unsafe(&self, ctx: &Context) -> HostPointer
Provided Methods§
sourcefn get_buffer_host_addr(&self, ctx: &Context) -> Option<HostPointer>
fn get_buffer_host_addr(&self, ctx: &Context) -> Option<HostPointer>
Returns native addr of wasm memory buffer in wasm executor