waPC FFI Functions

For the curious, here is the exact list of the waPC protocol’s functions. The guest always imports from a module called “wapc”, and all function names are preceded by two underscores to avoid accidental collisions with other exported functions.

FunctionOwnerDescription
__console_logHostGuest calls host to log to host’s stdout (if permitted)
__host_callHostGuest calls to request the host perform an operation
__host_responseHostTells the host the pointer address at which to store its response
__host_response_lenHostReturns the length of the host’s response
__host_errorHostTells the host the pointer address at which to store its error blob
__host_error_lenHostReturns the length of the host error blob
__guest_responseHostCalled by the guest to set the pointer and length of the guest’s response blob
__guest_errorHostCalled by the guest to set the pointer and length of the guest’s error blob
__guest_requestHostCalled by the guest to tell the host the pointer addresses of where to store the request’s operation (string) and request payload (blob) values.
__guest_callGuestInvoked by the host to tell the guest to begin processing a function call. The guest will then retrieve the parameters and set response values via host calls.

The waPC FFI functions are already taken care of for you in the existing guest and host libraries that you can find in the waPC organization. Built on top of those libraries, using waPC code generation from widl schemas, we have the wasmcloud actor-interfaces.

If you are interested in building your own language binding for waPC (and subsequently wasmcloud), check out the next section.