Crates.io | wasm-message-passing-3nweb |
lib.rs | wasm-message-passing-3nweb |
version | 0.2.0 |
source | src |
created_at | 2021-11-07 18:32:59.800552 |
updated_at | 2021-11-11 18:13:42.697192 |
description | Allows message passing between WASM instance and its embedding (like 3NWeb client platform) |
homepage | |
repository | https://github.com/3nsoft/wasm-message-passing-3nweb |
max_upload_size | |
id | 478184 |
size | 15,931 |
This crate allows communication (message passing) of code in WASM instances, invoked by 3NWeb platform(s).
wasm_mp1
)Module wasm_mp1
does message passing between a WASM instance and its embedding in accordance with version 1 of api.
Embedder provides imports a callback _3nweb_mp1_send_out_msg
in env
namespace. WASM code writes message bytes into its own memory and calls _3nweb_mp1_send_out_msg
with memory pointer and message length. Embedder must copy message content during this call, cause message exchange memory area is recycled and there are no guarantees about its content afterwards.
WASM exports functions _3nweb_mp1_get_buffer
and _3nweb_mp1_accept_msg
. These are used by embedder to send messages to WASM instance. Embedder sends message to WASM instance with following steps:
_3nweb_mp1_get_buffer
call,_3nweb_mp1_accept_msg
to let WASM instance know about the message.All three steps must be done without letting WASM instance to do anything else. This ensures that memory allocated in the first step won't be re-purposed, messing up everything.
LGPL-3.0 or greater version(s).