diff --git a/Cargo.lock b/Cargo.lock index 9ab3b47..74ae87b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5406,6 +5406,7 @@ dependencies = [ "spin-trigger", "tokio", "tracing", + "wasmtime-wasi", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 6eac81f..316e064 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,6 +24,7 @@ spin-factor-wasi = { git = "https://github.com/spinframework/spin", tag = "v3.2. spin-runtime-factors = { git = "https://github.com/spinframework/spin", tag = "v3.2.0" } tokio = { version = "1.38", features = ["rt", "macros"] } tracing = { version = "0.1", features = ["log"] } +wasmtime-wasi = "29.0.1" [target.'cfg(target_os = "linux")'.dependencies] # This needs to be an explicit dependency to enable diff --git a/examples/async/spin.toml b/examples/async/spin.toml index 7d26b49..4a6165e 100644 --- a/examples/async/spin.toml +++ b/examples/async/spin.toml @@ -10,6 +10,6 @@ description = "" component = "job" [component.job] -source = "target/wasm32-wasi/release/job.wasm" +source = "target/wasm32-wasip1/release/job.wasm" allowed_outbound_hosts = ["https://myip.fermyon.app/"] -build = ["cargo component build --target wasm32-wasi --release"] +build = ["cargo component build --target wasm32-wasip1 --release"] diff --git a/examples/hello-world/spin.toml b/examples/hello-world/spin.toml index d220417..2ba46ba 100644 --- a/examples/hello-world/spin.toml +++ b/examples/hello-world/spin.toml @@ -10,6 +10,5 @@ version = "0.1.0" component = "hello-world" [component.hello-world] -source = "target/wasm32-wasi/release/hello_world.wasm" -build = ["cargo component build --target wasm32-wasi --release"] - +source = "target/wasm32-wasip1/release/hello_world.wasm" +build = ["cargo component build --target wasm32-wasip1 --release"] diff --git a/src/lib.rs b/src/lib.rs index c701b58..03fb354 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -92,21 +92,9 @@ impl CommandTrigger { } let (instance, mut store) = instance_builder.instantiate(()).await?; - - let func = { - let instance_export = instance - .get_export(&mut store, None, "wasi:cli/run@0.2.0") - .context("failed to find the wasi:cli/run@0.2.0 instance in component")?; - - let func_export = instance - .get_export(&mut store, Some(&instance_export), "run") - .context("failed to find the \"run\" function in wasi:cli/run@0.2.0 instance")?; - - instance - .get_typed_func::<(), (Result<(), ()>,)>(&mut store, func_export) - .context("failed to get typed \"run\" function")? - }; - let _ = func.call_async(&mut store, ()).await?; + let func = wasmtime_wasi::bindings::Command::new(&mut store, &instance)?; + let func = func.wasi_cli_run(); + let _ = func.call_run(store).await?; Ok(()) }