From b0b4eba3b7ff5bfbcb8835c473ac3945c5160332 Mon Sep 17 00:00:00 2001 From: Henry Gressmann Date: Mon, 29 Jan 2024 17:31:01 +0100 Subject: feat: Bulk Memory Operations Proposal Signed-off-by: Henry Gressmann --- examples/wasm-rust.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'examples/wasm-rust.rs') diff --git a/examples/wasm-rust.rs b/examples/wasm-rust.rs index 468ab2e..96e3419 100644 --- a/examples/wasm-rust.rs +++ b/examples/wasm-rust.rs @@ -1,5 +1,5 @@ use color_eyre::eyre::Result; -use tinywasm::{Extern, FuncContext, Imports, Module, Store}; +use tinywasm::{Extern, FuncContext, Imports, MemoryStringExt, Module, Store}; fn main() -> Result<()> { let args = std::env::args().collect::>(); @@ -56,7 +56,7 @@ fn hello() -> Result<()> { "env", "print_utf8", Extern::typed_func(|mut ctx: FuncContext<'_>, args: (i64, i32)| { - let mem = ctx.memory("memory")?; + let mem = ctx.exported_memory("memory")?; let ptr = args.0 as usize; let len = args.1 as usize; let string = mem.load_string(ptr, len)?; @@ -69,7 +69,7 @@ fn hello() -> Result<()> { let arg_ptr = instance.exported_func::<(), i32>(&mut store, "arg_ptr")?.call(&mut store, ())?; let arg = b"world"; - instance.exported_memory(&mut store, "memory")?.store(arg_ptr as usize, arg.len(), arg)?; + instance.exported_memory_mut(&mut store, "memory")?.store(arg_ptr as usize, arg.len(), arg)?; let hello = instance.exported_func::(&mut store, "hello")?; hello.call(&mut store, arg.len() as i32)?; -- cgit v1.3.1