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

Method exports

crates/wasmtime/src/runtime/instance.rs:397–419  ·  view source on GitHub ↗

Returns the list of exported items from this [`Instance`]. # Panics Panics if `store` does not own this instance, or if memory allocation fails.

(
        &'a self,
        store: impl Into<StoreContextMut<'a, T>>,
    )

Source from the content-addressed store, hash-verified

395 /// Panics if `store` does not own this instance, or if memory allocation
396 /// fails.
397 pub fn exports<'a, T: 'static>(
398 &'a self,
399 store: impl Into<StoreContextMut<'a, T>>,
400 ) -> impl ExactSizeIterator<Item = Export<'a>> + 'a {
401 let store = store.into().0;
402 let store_id = store.id();
403 let engine = store.engine().clone();
404
405 let (instance, registry) = store.instance_and_module_registry_mut(self.id());
406 let (module, mut instance) = instance.module_and_self();
407 module.exports.iter().map(move |(name, entity)| {
408 // SAFETY: the `store_id` owns this instance and all exports
409 // contained within.
410 let export = unsafe {
411 instance
412 .as_mut()
413 .get_export_by_index_mut(registry, store_id, *entity)
414 };
415
416 let ext = Extern::from_wasmtime_export(export, &engine);
417 Export::new(&module.strings[name], ext)
418 })
419 }
420
421 /// Looks up an exported [`Extern`] value by name.
422 ///

Callers

nothing calls this directly

Calls 10

module_and_selfMethod · 0.80
newFunction · 0.50
idMethod · 0.45
cloneMethod · 0.45
engineMethod · 0.45
mapMethod · 0.45
iterMethod · 0.45
as_mutMethod · 0.45

Tested by

no test coverage detected