rvolosatovs opened PR #10586 from rvolosatovs:doc/pollable-fixup to bytecodealliance:main:
Usage example for
wasmtime_wasi::Pollableis displayed as:Instant) {} } } use tokio::time::{self, Duration, Instant}; use wasmtime_wasi_io::{IoView, poll::{Pollable, subscribe, DynPollable}, async_trait}; use wasmtime::component::Resource; use wasmtime::Result; fn sleep(cx: &mut dyn IoView, dur: Duration) -> Result<Resource<DynPollable>> { let end = Instant::now() + dur; let sleep = MySleep { end }; let sleep_resource = cx.table().push(sleep)?; subscribe(cx.table(), sleep_resource) } struct MySleep { end: Instant, } #[async_trait] impl Pollable for MySleep { async fn ready(&mut self) { tokio::time::sleep_until(self.end).await; } }which would not compile, if it were duplicated.
Note, that the doctests do not catch this issue, since the Rust code in the source is valid, however the displayed one is not due to
#only hiding part of the implementation
rvolosatovs requested wasmtime-core-reviewers for a review on PR #10586.
rvolosatovs requested alexcrichton for a review on PR #10586.
rvolosatovs edited PR #10586:
Usage example for
wasmtime_wasi::Pollablein v31.0.0 is displayed as:Instant) {} } } use tokio::time::{self, Duration, Instant}; use wasmtime_wasi_io::{IoView, poll::{Pollable, subscribe, DynPollable}, async_trait}; use wasmtime::component::Resource; use wasmtime::Result; fn sleep(cx: &mut dyn IoView, dur: Duration) -> Result<Resource<DynPollable>> { let end = Instant::now() + dur; let sleep = MySleep { end }; let sleep_resource = cx.table().push(sleep)?; subscribe(cx.table(), sleep_resource) } struct MySleep { end: Instant, } #[async_trait] impl Pollable for MySleep { async fn ready(&mut self) { tokio::time::sleep_until(self.end).await; } }which would not compile, if it were duplicated.
Note, that the doctests do not catch this issue, since the Rust code in the source is valid, however the displayed one is not due to
#only hiding part of the implementation
alexcrichton submitted PR review.
alexcrichton has enabled auto merge for PR #10586.
alexcrichton merged PR #10586.
Last updated: Dec 06 2025 at 06:05 UTC