You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I started to look around the wasi parts of the project and come to the realization that there is little customization in io when using the rust wasi c-api.
wasi:io/error: Is this a special object created with wasmtime_error_new()?
wasi:io/poll: All defined resources (like pollable) are host-managed wasm_val_t.of.ref host pointers?
How can I detect that a variable got dropped out of scope? Gc-drc collects inside the store? Docs says a store has no garbage collection. What does gc-drc collects?
wasi:io/poll: How to get a list<pollable> of objects? If I call the poll() func with a list of 3 pollable resources what do I get? Are they just a list of params? Will wasm_func_param_arity() return 3? Is it a table?
wasi:io/streams: How to return a result<>? Same question like the list<> argument but in reverse. How to return list<u8>, if the datatypes avaliable are i32, u32, i64, u64? Is it packed?
wasi:io/streams: With write() what is the return _? What to return here?
wasi:io/streams: At the end of blocking-write-and-flush() do I return the result of check-write()?
wasi:cli/environment: How to return a list<(string, string)>? is it a list<tuple<string, string>>? How strings are handled?
The text was updated successfully, but these errors were encountered:
Hi, that's correct, the C API only exports a very limited set of ways to configure a WASI 0.1 (aka Preview 1) implementation.
However, WASI has moved on to version 0.2, and with it wit is no longer based on bare Wasm Modules but on the Wasm Component Model proposal, which introduces a type system and interface definition language called wit. The wasi-cli repo link you refer to is the wit rendered as markdown. The ABIs for WASI 0.1 and 0.2 are completely different, and programs that are built to run on WASI 0.2 will not run on an implementation that only provides WASI 0.1. (There is a way to transform modules written against WASI 0.1 into components that use WASI 0.2.)The wasmtime-wasi crate provides both a 0.1 and 0.2 implementation, but only the 0.1 implementation is exposed when using the C API.
Unfortunately, the reason its not obvious for how to use any of those wit based types with wasmtime's C API is that wasmtimes C API does not yet have support for the component model. This is a long-standing bug that remains open because it is a big undertaking, and none of the core contributors who build and maintain Wasmtime as part of their jobs have been able to prioritize it, since our production use cases all use wasmtime through its native Rust API.
So, with that context, my suggestion is that you can take a look at using Wasmtime's Rust interfaces directly, where if you need a custom WASI implementation you have far more options, for example you could fork and modify the wasmtime-wasi crate, you could write a completely different implementation in Rust on top of the bindings created by wasmtime::component::bindgen!, such as in the example here. Alternatively, you can take on the C API issue yourself, which as warned above is also a pretty big undertaking.
I started to look around the wasi parts of the project and come to the realization that there is little customization in io when using the rust wasi c-api.
So I started to look around, how can I implement a small part of the proposed wasi interfaces.
I found this proposal: https://github.com/WebAssembly/wasi-cli/blob/main/command.md
I have a ton of questions.
wasmtime_error_new()
?pollable
) are host-managedwasm_val_t.of.ref
host pointers?list<pollable>
of objects? If I call thepoll()
func with a list of 3pollable
resources what do I get? Are they just a list of params? Willwasm_func_param_arity()
return 3? Is it atable
?result<>
? Same question like thelist<>
argument but in reverse. How to returnlist<u8>
, if the datatypes avaliable arei32
,u32
,i64
,u64
? Is it packed?write()
what is the return_
? What to return here?blocking-write-and-flush()
do I return the result ofcheck-write()
?list<(string, string)>
? is it alist<tuple<string, string>>
? How strings are handled?The text was updated successfully, but these errors were encountered: