A vector of bytes for WebAssembly.
This holds a Rust-style vector of bytes that lives in WebAssembly memory. There is the vector which is just the metadata, containing 3 32-bit integers, in a fixed location. The contents is in a location that is subject to change, when it resizes.
The 3 values are:
- Offset 0: the memory address of the data
- Offset 4: the length of the data
- Offset 8: the capacity
Allocating and resizing is taken care of in the WebAssembly process. The length can be changed here, or in the WebAssembly process. That way, data with a size that is less than the capacity, can be written outside of the WebAssembly instance so it can be passed to the WebAssembly instance. Data can be received from the WebAssembly instance by having it set the size and data, and resize as needed.