MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / resource_async

Method resource_async

crates/wasmtime/src/runtime/component/linker.rs:821–835  ·  view source on GitHub ↗
(&mut self, name: &str, ty: ResourceType, dtor: F)

Source from the content-addressed store, hash-verified

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")]

Callers 11

drop_resource_asyncFunction · 0.80
add_to_linker_importsMethod · 0.80
add_to_linker_instanceFunction · 0.80
add_to_linker_instanceFunction · 0.80
add_to_linker_importsMethod · 0.80
add_to_linker_instanceFunction · 0.80
add_to_linker_importsMethod · 0.80
add_to_linker_instanceFunction · 0.80
add_to_linker_importsMethod · 0.80
add_to_linker_instanceFunction · 0.80
add_to_linker_instanceFunction · 0.80

Calls 3

OkFunction · 0.85
ResourceClass · 0.50
insertMethod · 0.45

Tested by 10

add_to_linker_importsMethod · 0.64
add_to_linker_instanceFunction · 0.64
add_to_linker_instanceFunction · 0.64
add_to_linker_importsMethod · 0.64
add_to_linker_instanceFunction · 0.64
add_to_linker_importsMethod · 0.64
add_to_linker_instanceFunction · 0.64
add_to_linker_importsMethod · 0.64
add_to_linker_instanceFunction · 0.64
add_to_linker_instanceFunction · 0.64