Stream: wasi

Topic: ✔ What is WasiView used for?


view this post on Zulip Ari Seyhun (May 15 2023 at 08:34):

I'm updating some old code which used the preview2-prototyping crates to use wasm components, and it seems like I now need to implement WasiView for a context: <https://github.com/bytecodealliance/preview2-prototyping/blob/main/host/src/main.rs#L96>
I also see the Table has been introduced as a requirement too. Sadly these types have no code docs yet.
What is WasiView and the table used for exactly?

Polyfill adapter for preview1-using wasm modules to call preview2 functions. - preview2-prototyping/main.rs at main · bytecodealliance/preview2-prototyping

view this post on Zulip Pat Hickey (May 15 2023 at 17:02):

hi, yes, all of that code does need new docs written

view this post on Zulip Pat Hickey (May 15 2023 at 17:03):

in short the explanation is: previously, WasiCtx owned a Table, so it was just an implementation detail never exposed to the user

view this post on Zulip Pat Hickey (May 15 2023 at 17:04):

its still an implementation detail - the user shouldnt ever have to interact with table directly, WasiCtxBuilder and WasiView should take care of it - but we needed to enable sharing the same Table across many different crates implementing different chunks of wasi preview 2

view this post on Zulip Pat Hickey (May 15 2023 at 17:06):

so, the user is responsible for creating one single Table, using it to build their WasiCtx as well as any other ctxs that need it, and then making it a member of their T in Store<T> struct, and providing WasiView impl on that T

view this post on Zulip Pat Hickey (May 15 2023 at 17:07):

if you take a look in host/src/main.rs or host/tests/command.rs you can see examples of how this should look

view this post on Zulip Pat Hickey (May 15 2023 at 17:08):

and i suppose we can package in a more convenient version of that

view this post on Zulip Notification Bot (May 16 2023 at 13:04):

Ari Seyhun has marked this topic as resolved.


Last updated: Oct 23 2024 at 20:03 UTC