-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Labels
c-apilibwasm_runtime C APIlibwasm_runtime C API💡looking for ideasIssue under discussion and looking for new ideasIssue under discussion and looking for new ideas🚀 enhancementNew feature or requestNew feature or request
Description
@ereslibre initiated an interesting discussion about the return value types in the C API.
Currently, some functions return a *const c_char
as a result:
pub extern "C" fn wasm_executionctx_run(executionctx_id: *const c_char) -> *const c_char
pub extern "C" fn wasm_executionctx_create_from_config(config_id: *const c_char) -> *const c_char {
So there is no formal way to distinguish whether the returned data is the expected output or a text explaining the error.
We should explore returning a CResult
that looks like this:
struct CResult {
bool succeeded;
char *result;
};
Or we could go for this other approach of result-type-in.c.
An example of mod_wasm.c code that is missing error logging is the Wasm execution invocation. We don't know if the returned string was the expected output or not.
const char* module_response = wasm_executionctx_run(exec_ctx_id);
In any case, we should take care of returning the string ownership to Rust.
I am opening this issue to have a discussion about it.
Metadata
Metadata
Assignees
Labels
c-apilibwasm_runtime C APIlibwasm_runtime C API💡looking for ideasIssue under discussion and looking for new ideasIssue under discussion and looking for new ideas🚀 enhancementNew feature or requestNew feature or request