wasmtime-wasi: introduce WasiP1Ctx #8053
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds
wasmtime_wasi::WasiP1Ctx
, which is aWasiCtx
for just using WASI P1 (and P0).This simplifies user experience for users migrating from wasi-common's P1 support - it means they don't have to know about the
*View
traits or theWasiPreview1Adapter
, which are just implementation details to a P1 embedder.The p1/p0
add_to_linker_{a?}sync
functions now take a closure that is the lens for the T in Store, to be consistent with wasi-common and in general whatwasmtime::Linker
users expect.WasiCtxBuilder now has a convenient function
build_p1(&mut self) -> WasiP1Ctx
that can be used in the place ofbuild(&mut self) -> WasiCtx
for users targeting a P1 embedding.This PR also adds two trivial methods to WasiCtxBuilder to reflect ones that existed in wasi-common;s:
inherit_env
andinherit_args
.Finally, this PR adds
AsyncStdinStream
andAsyncStdoutStream
as wrappers onAsyncReadStream
andAsyncWriteStream
to provide implementations ofStdinStream
andStdoutStream
. (This could be separated into a totally different PR, but it doesnt seem worth the e-paperwork overhead to bother.) These provide parity with the wasi-common affordances for piping stdio to/from files, which happen to be used in the c-api.The top-level tests and examples that were using
wasi-common
are updated to usewasmtime-wasi::WasiP1Ctx
.