pub fn write_bytes(v: Vec<u8>) -> usize
Expand description

Given an owned vector of bytes, leaks it and returns a pointer the host can use to read the bytes. This does NOT handle the length of the bytes, so the guest will need to track the length separately from leaking the vector.

This facilitates the guest handing a GuestPtr back to the host as the return value of guest functions so that the host can read the output of guest logic from a pointer.

The host MUST ensure either __hc__deallocate_1 is called or the entire wasm memory is dropped. If the host fails to tell the guest where and how many bytes to deallocate, then this leak becomes permanent to the guest.