When instantiating your WebAssembly module, we can pass along an object which contains the functions to be passed to the module inside the end property. We leverage this to provide our function to the WebAssembly module.
Then we switch over to our Rust code. There, we also have to declare which function we want to use. In our case, that's appendNumberToBody. The parameter of the function should be an unsigned integer.
Now we need to use appendNumberToBody. Therefore, we export the function run. Inside run, we invoke appendNumberToBody. Note that we have to wrap it with an unsafe block, since the Rust compiler can't provide memory safety guarantees for external functions.
Let's add one more. In this case, we'll pass the native function inaudible to our module. We import the function, invoke it inside of our unsafe block. Then we recompile and reload the page in our browser. Great. This even works with native browser functions, since we can see the inaudible dialogue.