Building our kernel
Our kernel just houses the struct for the JSON body. Seeing as the JSON body is used to send the WASM compute unit to the server and put the WASM compute unit onto the Redis queue, all client, server, and worker Rust workspaces will need to reference this struct that supports JSON serialization. Considering our JSON dependency, the kernel’s Cargo.toml file takes the following form:
# kernel/Cargo.toml
[package]
name = "kernel"
version = "0.1.0"
edition = "2021"
[dependencies]
serde = { version = "1.0", features = ["derive"] }
Now that we have defined our dependencies, we can build our JSON payload struct with the following code:
// File: kernel/src/lib.rs
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize)]
pub struct Payload {
pub memory: Vec<u8>,
pub contract: Vec<u8>,
}
For our payload struct, we store the WASM compute unit in the contract...