MCPcopy Index your code
hub / github.com/explodingcamera/tinywasm / tinywasm

Function tinywasm

examples/wasm-rust.rs:73–86  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

71}
72
73fn tinywasm() -> Result<()> {
74 let module = tinywasm::parse_file("./examples/rust/out/tinywasm.opt.wasm")?;
75 let mut store = Store::default();
76
77 let mut imports = Imports::new();
78 imports.define("env", "printi32", HostFunction::from(&mut store, |_: FuncContext<'_>, _x: i32| Ok(())));
79 let instance = ModuleInstance::instantiate(&mut store, &module, Some(black_box(imports)))?;
80
81 let hello = instance.func::<(), ()>(&store, "hello")?;
82 hello.call(&mut store, black_box(()))?;
83 hello.call(&mut store, black_box(()))?;
84 hello.call(&mut store, black_box(()))?;
85 Ok(())
86}
87
88fn tinywasm_no_std() -> Result<()> {
89 let module = tinywasm::parse_file("./examples/rust/out/tinywasm_no_std.wasm")?;

Callers 2

mainFunction · 0.85
test_tinywasmFunction · 0.85

Calls 3

parse_fileFunction · 0.85
defineMethod · 0.80
callMethod · 0.80

Tested by 1

test_tinywasmFunction · 0.68