Building a WASM library
For our WASM library, we are going to receive a pointer and length to the serialized struct in memory, we are then going to carry out the following steps:
- receive a pointer to a serialized struct in memory and a length.
- extract the bytes of the struct from memory.
- deserialize the struct.
- add a name to the struct.
- serialize the updated struct to bytes.
- put the serialized struct into memory.
- return the pointer to the memory address of the updated serialized structs.
While these numbered steps help distill what we are carrying out, we will not break down the implementation of our WASM library into numbered steps, as the implementation of these numbered steps come all at the end when the entry point function is built.
Before we write any code, our WASM library has the following dependencies:
// File: wasm-lib/Cargo.toml
[dependencies]
bincode = "1.3.3"
kernel = { path = "../kernel" }
serde = { version = "1.0.201", features = ["...