Skip to content

Conversation

@dblnz
Copy link
Contributor

@dblnz dblnz commented May 16, 2025

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 what call_host_function used to. In addition I added call_host_function<T> which calls the call_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.

@dblnz dblnz added kind/refactor For PRs that restructure or remove code without adding new functionality. kind/enhancement For PRs adding features, improving functionality, docs, tests, etc. and removed kind/refactor For PRs that restructure or remove code without adding new functionality. labels May 16, 2025
@dblnz dblnz force-pushed the guest-call-host-function-improvements branch from 0e30b70 to 63e7d7c Compare May 16, 2025 11:42
@dblnz dblnz force-pushed the guest-call-host-function-improvements branch from 63e7d7c to e06d40a Compare May 16, 2025 13:29
Copy link
Contributor

@ludfjig ludfjig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, nice improvement

@dblnz dblnz merged commit 861d4a5 into hyperlight-dev:main May 19, 2025
27 checks passed
@dblnz dblnz deleted the guest-call-host-function-improvements branch May 19, 2025 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/enhancement For PRs adding features, improving functionality, docs, tests, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants