fix wasi example

This commit is contained in:
Pat Hickey
2021-01-29 15:43:30 -08:00
parent 2ad7565a65
commit 5ee605995d

View File

@@ -4,8 +4,9 @@
// You can execute this example with `cargo run --example wasi`
use anyhow::Result;
use wasi_cap_std_sync::WasiCtxBuilder;
use wasmtime::*;
use wasmtime_wasi::{Wasi, WasiCtx};
use wasmtime_wasi::Wasi;
fn main() -> Result<()> {
tracing_subscriber::FmtSubscriber::builder()
@@ -19,7 +20,13 @@ fn main() -> Result<()> {
// Create an instance of `Wasi` which contains a `WasiCtx`. Note that
// `WasiCtx` provides a number of ways to configure what the target program
// will have access to.
let wasi = Wasi::new(&store, WasiCtx::new(std::env::args())?);
let wasi = Wasi::new(
&store,
WasiCtxBuilder::new()
.inherit_stdio()
.inherit_args()?
.build()?,
);
wasi.add_to_linker(&mut linker)?;
// Instantiate our module with the imports we've created, and run it.