Stream: general

Topic: How to pass a rust string into wasm module?


view this post on Zulip Dennis Zhang (Nov 18 2022 at 03:38):

How to pass a string into wasm then manipulate it, then return with a new string defined in wasm? is there any example for this?

view this post on Zulip Dennis Zhang (Nov 18 2022 at 07:09):

can I pass a tcp connection to wasm module and handle it as a File? If I implement the WasiFile trait for it

view this post on Zulip Lann Martin (Nov 18 2022 at 14:27):

As of wasmtime 1.0 you don't even need to implement WasiFile: https://docs.rs/wasmtime-wasi/2.0.2/wasmtime_wasi/sync/struct.WasiCtxBuilder.html#method.preopened_socket

view this post on Zulip Dennis Zhang (Nov 19 2022 at 08:00):

what does the fd in the function mean? the fd of the opened socket?

view this post on Zulip bjorn3 (Nov 19 2022 at 09:27):

The fd that will be assigned to the socket in the guest.

view this post on Zulip Dennis Zhang (Nov 19 2022 at 10:20):

okay thanks, I will try it out

view this post on Zulip Dennis Zhang (Nov 19 2022 at 12:31):

Lann Martin said:

As of wasmtime 1.0 you don't even need to implement WasiFile: https://docs.rs/wasmtime-wasi/2.0.2/wasmtime_wasi/sync/struct.WasiCtxBuilder.html#method.preopened_socket

I am quite confused on this function, the Into<Socket> requires cap_std::net::TcpStream, while that is based on non-wasi feature, which is kind of confusing, can you possibly explain it to me? thanks

view this post on Zulip Dennis Zhang (Nov 19 2022 at 14:49):

Can anyone show me a very simple example of that function usage? I really don't know how to handle it correctly.


Last updated: Nov 22 2024 at 16:03 UTC