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