Function holochain_wasmer_guest::host_call [−][src]
pub fn host_call<I, O>(
f: unsafe extern "C" fn(_: GuestPtr) -> Len,
input: I
) -> Result<O, WasmError> where
I: Serialize + Debug,
O: DeserializeOwned + Debug,
Given an GuestPtr
-> Len
extern that we expect the host to provide:
- Serialize the payload by reference
- Write the bytes into a new allocation
- Call the host function and pass it the pointer to our allocation full of serialized data
- Deallocate the serialized bytes when the host function completes
- Allocate empty bytes of the length that the host tells us the result is
- Ask the host to write the result into the allocated empty bytes
- Deserialize and deallocate whatever bytes the host has written into the result allocation
- Return a Result of the deserialized output type O