(link_options: &LinkOptions)
| 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 | |
| 912 | mod anyhow_errors { |
no test coverage detected