diff --git a/Cargo.lock b/Cargo.lock index ea8cb56aed..b4c9069bd9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3533,6 +3533,7 @@ name = "wasmtime-wasi" version = "0.26.0" dependencies = [ "anyhow", + "wasi-cap-std-async", "wasi-cap-std-sync", "wasi-common", "wasmtime", diff --git a/crates/wasi/Cargo.toml b/crates/wasi/Cargo.toml index 9951e446a6..da5557f1b7 100644 --- a/crates/wasi/Cargo.toml +++ b/crates/wasi/Cargo.toml @@ -15,6 +15,7 @@ build = "build.rs" [dependencies] wasi-common = { path = "../wasi-common", version = "0.26.0" } wasi-cap-std-sync = { path = "../wasi-common/cap-std-sync", version = "0.26.0", optional = true } +wasi-cap-std-async = { path = "../wasi-common/cap-std-async", version = "0.26.0", optional = true } wiggle = { path = "../wiggle", default-features = false, version = "0.26.0" } wasmtime-wiggle = { path = "../wiggle/wasmtime", default-features = false, version = "0.26.0" } wasmtime = { path = "../wasmtime", default-features = false, version = "0.26.0" } @@ -23,3 +24,4 @@ anyhow = "1.0" [features] default = ["sync"] sync = ["wasi-cap-std-sync"] +async = ["wasi-cap-std-async", "wasmtime/async", "wasmtime-wiggle/async"] diff --git a/crates/wasi/src/lib.rs b/crates/wasi/src/lib.rs index 2b71d7ab37..31045041d3 100644 --- a/crates/wasi/src/lib.rs +++ b/crates/wasi/src/lib.rs @@ -20,6 +20,13 @@ pub mod sync { pub use wasi_cap_std_sync::*; } +/// Re-export the wasi-cap-std-async crate here. This saves consumers of this library from having +/// to keep additional dependencies in sync. +#[cfg(feature = "async")] +pub mod async_ { + pub use wasi_cap_std_async::*; +} + /// An instantiated instance of all available wasi exports. Presently includes /// both the "preview1" snapshot and the "unstable" (preview0) snapshot. pub struct Wasi { @@ -79,6 +86,7 @@ necessary. Additionally [`Wasi::get_export`] can be used to do name-based resolution.", }, }, + async: { wasi_snapshot_preview1::{ poll_oneoff, sched_yield } } }); } pub mod preview_0 { @@ -106,6 +114,7 @@ necessary. Additionally [`Wasi::get_export`] can be used to do name-based resolution.", }, }, + async: { wasi_unstable::{ poll_oneoff, sched_yield } } }); } }