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

Method to_func

crates/wasmtime/src/runtime/func.rs:2696–2703  ·  view source on GitHub ↗

Inserts this `HostFunc` into a `Store`, returning the `Func` pointing to it. # Unsafety Can only be inserted into stores with a matching `T` relative to when this `HostFunc` was first created.

(self: &Arc<Self>, store: &mut StoreOpaque)

Source from the content-addressed store, hash-verified

2694 /// Can only be inserted into stores with a matching `T` relative to when
2695 /// this `HostFunc` was first created.
2696 pub unsafe fn to_func(self: &Arc<Self>, store: &mut StoreOpaque) -> Result<Func, OutOfMemory> {
2697 self.validate_store(store);
2698 let (funcrefs, modules) = store.func_refs_and_modules();
2699 let funcref = funcrefs.push_arc_host(self.clone(), modules)?;
2700 // SAFETY: this funcref was just pushed within the store, so it's safe
2701 // to say this store owns it.
2702 Ok(unsafe { Func::from_vm_func_ref(store.id(), funcref) })
2703 }
2704
2705 /// Inserts this `HostFunc` into a `Store`, returning the `Func` pointing to
2706 /// it.

Callers 1

to_externMethod · 0.80

Calls 6

OkFunction · 0.85
validate_storeMethod · 0.80
func_refs_and_modulesMethod · 0.80
push_arc_hostMethod · 0.80
cloneMethod · 0.45
idMethod · 0.45

Tested by

no test coverage detected