wasmtime_wasi/
poll.rs

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