guest: make call_host_function
generic to avoid two steps to retrieve return value
#500
+55
−36
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
As the title says, this changes the
call_host_function
function to return a generic type.Details
The reason behind this change is to avoid calling the host function and getting the result in a separate step.
For the C guests we still need to do it in two steps as it does not support generic types.
To avoid code duplication I added a
call_host_function_internal
that does whatcall_host_function
used to. In addition I addedcall_host_function<T>
which calls thecall_host_function_internal
and also retrieves the return value.This approach allows us to use a generic function to call and retrieve the return value in Rust and we can use
call_host_function_internal
for C guests.