0
votes

Hey @all I was playing with WebAssembly Studio and created an empty Rust project.

In my Rust code, I'm returning the pointer and the length for my "Hello World" string. Compiling worked fine, but I was expecting the resulting WASM to have a function returning two i32. But I found a function taking one i32 and returning nothing.

  1. Why is the function not having the signature fn () -> (i32,i32) ?

  2. How am I supposed to extract the two values from the WASM module? (Using Rust-wasmtime)

Below you can find the code snippets I'm talking about. Thanks in advance!

#[no_mangle]
pub extern "C" fn say() -> (*const u8,i32)  {
    let pointcut = "Hello World";

    (pointcut.as_ptr(),11)
}
(module
  (type $t0 (func (param i32)))
  (func $say (export "say") (type $t0) (param $p0 i32)
    get_local $p0
    i32.const 11
    i32.store offset=4
    get_local $p0
    i32.const 1024
    i32.store)
  (table $T0 1 1 anyfunc)
  (memory $memory (export "memory") 17)
  (data (i32.const 1024) "Hello World"))