1use crate::runtime::in_tokio;
2use wasmtime_wasi_io::{bindings::wasi::io::poll as async_poll, poll::DynPollable};
3
4use anyhow::Result;
5use wasmtime::component::{Resource, ResourceTable};
6
7impl crate::p2::bindings::sync::io::poll::Host for ResourceTable {
8 fn poll(&mut self, pollables: Vec<Resource<DynPollable>>) -> Result<Vec<u32>> {
9 in_tokio(async { async_poll::Host::poll(self, pollables).await })
10 }
11}
12
13impl crate::p2::bindings::sync::io::poll::HostPollable for ResourceTable {
14 fn ready(&mut self, pollable: Resource<DynPollable>) -> Result<bool> {
15 in_tokio(async { async_poll::HostPollable::ready(self, pollable).await })
16 }
17 fn block(&mut self, pollable: Resource<DynPollable>) -> Result<()> {
18 in_tokio(async { async_poll::HostPollable::block(self, pollable).await })
19 }
20 fn drop(&mut self, pollable: Resource<DynPollable>) -> Result<()> {
21 async_poll::HostPollable::drop(self, pollable)
22 }
23}