This crate provides the WebAssembly-side logic for wasmRS modules using the wasmRS RSocket protocol.
This is a basic implementation of a WebAssembly module that exports three operations:
greeting::sayHello(input: string) -> string
- returns a greeting, e.g. `Hello World!'echo::chars(input: string) -> stream string
- returns a stream of string
representing each character in the input stringecho::reverse(input: stream string) -> stream string
- reverses each string
from the input stream and outputs it on a stream.```rs use guest::*; use wasmrs_guest as guest;
extern "C" fn _wasmrsinit(guestbuffersize: u32, hostbuffersize: u32, maxhostframelen: u32) { guest::init(guestbuffersize, hostbuffersize, maxhostframelen);
guest::registerrequestresponse("greeting", "sayHello", requestresponse); guest::registerrequeststream("echo", "chars", requeststream); guest::registerrequestchannel("echo", "reverse", request_channel); }
fn requestresponse(input: Mono
fn requeststream(
input: Mono
Ok(rx)
}
fn requestchannel(
mut input: FluxReceiver
Ok(rx) } ```
NanoBus iota code generators use the wasmRS protocol. You can build wasmRS
modules from those templates using the https://github.com/apexlang/apex
CLI.
Run the following command to get started:
sh
$ apex new git@github.com:nanobus/iota.git -p templates/rust [your-project]
From there, edit the apex.axdl
interface definition to match your needs and run apex build
to generate the wasmRS module.
WasmRS makes heavy use of generated code from apex
specs and generators to automate all of the boilerplate. See the getting-started for NanoBus for up-to-date usage.
For more information on wasmRS, see the core wasmrs crate.
See CONTRIBUTING.md
See the root LICENSE.txt