Skip to content

Commit ae81493

Browse files
committed
chore: adapt to Accessor API changes
- hide `CommandPre`, since it is currently unusable #11249 - use `Command::new` directly in examples, since `instantiate_async` does not provide a way to call an export Signed-off-by: Roman Volosatovs <[email protected]>
1 parent 0cfdb2e commit ae81493

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

crates/wasi/src/p3/bindings.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,11 @@ pub use self::generated::wasi::*;
220220
/// );
221221
///
222222
/// // Instantiate the component and we're off to the races.
223-
/// let command = Command::instantiate_async(&mut store, &component, &linker).await?;
224-
/// let program_result = command.wasi_cli_run().call_run(&mut store).await?;
223+
/// let instance = linker.instantiate_async(&mut store, &component).await?;
224+
/// let command = Command::new(&mut store, &instance)?;
225+
/// let program_result = instance.run_with(&mut store, async move |store| {
226+
/// command.wasi_cli_run().call_run(store).await
227+
/// }).await??;
225228
/// match program_result {
226229
/// Ok(()) => Ok(()),
227230
/// Err(()) => std::process::exit(1),
@@ -286,7 +289,10 @@ pub use self::generated::Command;
286289
///
287290
/// // Instantiate the component and we're off to the races.
288291
/// let command = pre.instantiate_async(&mut store).await?;
289-
/// let program_result = command.wasi_cli_run().call_run(&mut store).await?;
292+
/// // TODO: Construct an accessor from `store` to call `run`
293+
/// // https://github.com/bytecodealliance/wasmtime/issues/11249
294+
/// //let program_result = command.wasi_cli_run().call_run(&mut store).await?;
295+
/// let program_result = todo!();
290296
/// match program_result {
291297
/// Ok(()) => Ok(()),
292298
/// Err(()) => std::process::exit(1),
@@ -303,6 +309,10 @@ pub use self::generated::Command;
303309
/// ```
304310
///
305311
/// ---
312+
// TODO: Make this public, once `CommandPre` can be used for
313+
// calling exports
314+
// https://github.com/bytecodealliance/wasmtime/issues/11249
315+
#[doc(hidden)]
306316
pub use self::generated::CommandPre;
307317

308318
pub use self::generated::CommandIndices;

crates/wasi/src/p3/clocks/host.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ where
4747
T: WasiClocksView + 'static,
4848
{
4949
async fn wait_until<U>(
50-
store: &mut Accessor<U, Self>,
50+
store: &Accessor<U, Self>,
5151
when: monotonic_clock::Instant,
5252
) -> wasmtime::Result<()> {
5353
let clock_now = store.with(|mut view| view.get().clocks().monotonic_clock.now());
@@ -58,7 +58,7 @@ where
5858
}
5959

6060
async fn wait_for<U>(
61-
_store: &mut Accessor<U, Self>,
61+
_store: &Accessor<U, Self>,
6262
duration: monotonic_clock::Duration,
6363
) -> wasmtime::Result<()> {
6464
if duration > 0 {

crates/wasi/tests/all/p3/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,10 @@ async fn run(path: &str) -> anyhow::Result<()> {
7777
let instance = linker.instantiate_async(&mut store, &component).await?;
7878
let command =
7979
Command::new(&mut store, &instance).context("failed to instantiate `wasi:cli/command`")?;
80-
let run = command.wasi_cli_run().call_run(&mut store);
8180
instance
82-
.run(&mut store, run)
81+
.run_with(&mut store, async move |store| {
82+
command.wasi_cli_run().call_run(store).await
83+
})
8384
.await
8485
.context("failed to call `wasi:cli/run#run`")?
8586
.context("guest trapped")?

0 commit comments

Comments
 (0)