Function holochain_wasmer_guest::allocation::write_bytes [−][src]
pub fn write_bytes(v: Vec<u8>) -> GuestPtr
Expand description
Attempt to write a slice of bytes.
This is identical to the following:
- host has some slice of bytes
- host calls __allocate with the slice length
- guest returns GuestPtr to the host
- host writes the bytes into the guest at GuestPtr location
- host hands the GuestPtr back to the guest
In this case everything happens within the guest and a GuestPtr is returned if successful.
This also leaks the written bytes, exactly like the above process.
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 __deallocate is called or the entire wasm memory is dropped.