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

Function run_with_options

tests/all/component_model/bindgen.rs:872–909  ·  view source on GitHub ↗
(link_options: &LinkOptions)

Source from the content-addressed store, hash-verified

870 }
871
872 fn run_with_options(link_options: &LinkOptions) -> Result<()> {
873 let engine = engine();
874
875 let component = Component::new(
876 &engine,
877 r#"
878 (component
879 (import "foo:foo/my-interface" (instance $i
880 (export "my-function" (func))
881 ))
882 (core module $m
883 (import "" "" (func))
884 (export "" (func 0))
885 )
886 (core func $f (canon lower (func $i "my-function")))
887 (core instance $r (instantiate $m
888 (with "" (instance (export "" (func $f))))
889 ))
890
891 (func $f (export "bar") (canon lift (core func $r "")))
892 )
893 "#,
894 )?;
895
896 #[derive(Default)]
897 struct MyHost;
898
899 impl foo::foo::my_interface::Host for MyHost {
900 fn my_function(&mut self) {}
901 }
902
903 let mut linker = Linker::new(&engine);
904 MyWorld::add_to_linker::<_, HasSelf<_>>(&mut linker, link_options, |h| h)?;
905 let mut store = Store::new(&engine, MyHost::default());
906 let one_import = MyWorld::instantiate(&mut store, &component, &linker)?;
907 one_import.call_bar(&mut store)?;
908 Ok(())
909 }
910}
911
912mod anyhow_errors {

Callers 2

assert_successFunction · 0.85
assert_failureFunction · 0.85

Calls 4

OkFunction · 0.85
engineFunction · 0.50
newFunction · 0.50
instantiateFunction · 0.50

Tested by

no test coverage detected