| 819 | /// Identical to [`Self::resource`], except that it takes an async destructor. |
| 820 | #[cfg(feature = "async")] |
| 821 | pub fn resource_async<F>(&mut self, name: &str, ty: ResourceType, dtor: F) -> Result<()> |
| 822 | where |
| 823 | T: Send, |
| 824 | F: Fn(StoreContextMut<'_, T>, u32) -> Box<dyn Future<Output = Result<()>> + Send + '_> |
| 825 | + Send |
| 826 | + Sync |
| 827 | + 'static, |
| 828 | { |
| 829 | let dtor = try_new::<Arc<_>>(crate::func::HostFunc::wrap_async( |
| 830 | &self.engine, |
| 831 | move |cx: crate::Caller<'_, T>, (param,): (u32,)| dtor(cx.into(), param), |
| 832 | )?)?; |
| 833 | self.insert(name, Definition::Resource(ty, dtor))?; |
| 834 | Ok(()) |
| 835 | } |
| 836 | |
| 837 | /// Identical to [`Self::resource`], except that it takes a concurrent destructor. |
| 838 | #[cfg(feature = "component-model-async")] |