Host exports
Host export is a function exported from a host and accessible by a Wasm module. Without interface-types it's not so easy to make a convenient API without the necessity for a developer to think about some low-level details (such as memory allocation for passing complex data types).
Marine makes the development of such functions a trivial task. Each of such functions should be registered in the runtime config with HostImportDescriptor.
rust
rust
And that is how a real-world host exports looks like:
rust
rust
Take a look at how host_cmd_closure is defined, it has two arguments: Ctx could be used for some low-level stuff, while args represents closure arguments and it's an array of IValue, which could be handled in a handy way then. The result of the closure is Option<IValue>, and resulted IValue could be easily constructed with a special function to_interface_value.
And that's it! Just handle arguments, convert the result to IValue, and provide a descriptor!