1 /// Auto-generated bindings for a pre-instantiated version of a 2 /// component which implements the world `the-world`. 3 /// 4 /// This structure is created through [`TheWorldPre::new`] which 5 /// takes a [`InstancePre`](wasmtime::component::InstancePre) that 6 /// has been created through a [`Linker`](wasmtime::component::Linker). 7 /// 8 /// For more information see [`TheWorld`] as well. 9 pub struct TheWorldPre<T> { 10 instance_pre: wasmtime::component::InstancePre<T>, 11 indices: TheWorldIndices, 12 } 13 impl<T> Clone for TheWorldPre<T> { 14 fn clone(&self) -> Self { 15 Self { 16 instance_pre: self.instance_pre.clone(), 17 indices: self.indices.clone(), 18 } 19 } 20 } 21 impl<_T> TheWorldPre<_T> { 22 /// Creates a new copy of `TheWorldPre` bindings which can then 23 /// be used to instantiate into a particular store. 24 /// 25 /// This method may fail if the component behind `instance_pre` 26 /// does not have the required exports. 27 pub fn new( 28 instance_pre: wasmtime::component::InstancePre<_T>, 29 ) -> wasmtime::Result<Self> { 30 let indices = TheWorldIndices::new(&instance_pre)?; 31 Ok(Self { instance_pre, indices }) 32 } 33 pub fn engine(&self) -> &wasmtime::Engine { 34 self.instance_pre.engine() 35 } 36 pub fn instance_pre(&self) -> &wasmtime::component::InstancePre<_T> { 37 &self.instance_pre 38 } 39 /// Instantiates a new instance of [`TheWorld`] within the 40 /// `store` provided. 41 /// 42 /// This function will use `self` as the pre-instantiated 43 /// instance to perform instantiation. Afterwards the preloaded 44 /// indices in `self` are used to lookup all exports on the 45 /// resulting instance. 46 pub async fn instantiate_async( 47 &self, 48 mut store: impl wasmtime::AsContextMut<Data = _T>, 49 ) -> wasmtime::Result<TheWorld> 50 where 51 _T: Send + 'static, 52 { 53 let mut store = store.as_context_mut(); 54 let instance = self.instance_pre.instantiate_async(&mut store).await?; 55 self.indices.load(&mut store, &instance) 56 } 57 } 58 /// Auto-generated bindings for index of the exports of 59 /// `the-world`. 60 /// 61 /// This is an implementation detail of [`TheWorldPre`] and can 62 /// be constructed if needed as well. 63 /// 64 /// For more information see [`TheWorld`] as well. 65 #[derive(Clone)] 66 pub struct TheWorldIndices { 67 interface0: exports::foo::foo::simple::GuestIndices, 68 } 69 /// Auto-generated bindings for an instance a component which 70 /// implements the world `the-world`. 71 /// 72 /// This structure can be created through a number of means 73 /// depending on your requirements and what you have on hand: 74 /// 75 /// * The most convenient way is to use 76 /// [`TheWorld::instantiate_async`] which only needs a 77 /// [`Store`], [`Component`], and [`Linker`]. 78 /// 79 /// * Alternatively you can create a [`TheWorldPre`] ahead of 80 /// time with a [`Component`] to front-load string lookups 81 /// of exports once instead of per-instantiation. This 82 /// method then uses [`TheWorldPre::instantiate_async`] to 83 /// create a [`TheWorld`]. 84 /// 85 /// * If you've instantiated the instance yourself already 86 /// then you can use [`TheWorld::new`]. 87 /// 88 /// These methods are all equivalent to one another and move 89 /// around the tradeoff of what work is performed when. 90 /// 91 /// [`Store`]: wasmtime::Store 92 /// [`Component`]: wasmtime::component::Component 93 /// [`Linker`]: wasmtime::component::Linker 94 pub struct TheWorld { 95 interface0: exports::foo::foo::simple::Guest, 96 } 97 const _: () = { 98 #[allow(unused_imports)] 99 use wasmtime::component::__internal::anyhow; 100 impl TheWorldIndices { 101 /// Creates a new copy of `TheWorldIndices` bindings which can then 102 /// be used to instantiate into a particular store. 103 /// 104 /// This method may fail if the component does not have the 105 /// required exports. 106 pub fn new<_T>( 107 _instance_pre: &wasmtime::component::InstancePre<_T>, 108 ) -> wasmtime::Result<Self> { 109 let _component = _instance_pre.component(); 110 let _instance_type = _instance_pre.instance_type(); 111 let interface0 = exports::foo::foo::simple::GuestIndices::new( 112 _instance_pre, 113 )?; 114 Ok(TheWorldIndices { interface0 }) 115 } 116 /// Uses the indices stored in `self` to load an instance 117 /// of [`TheWorld`] from the instance provided. 118 /// 119 /// Note that at this time this method will additionally 120 /// perform type-checks of all exports. 121 pub fn load( 122 &self, 123 mut store: impl wasmtime::AsContextMut, 124 instance: &wasmtime::component::Instance, 125 ) -> wasmtime::Result<TheWorld> { 126 let _ = &mut store; 127 let _instance = instance; 128 let interface0 = self.interface0.load(&mut store, &_instance)?; 129 Ok(TheWorld { interface0 }) 130 } 131 } 132 impl TheWorld { 133 /// Convenience wrapper around [`TheWorldPre::new`] and 134 /// [`TheWorldPre::instantiate_async`]. 135 pub async fn instantiate_async<_T>( 136 store: impl wasmtime::AsContextMut<Data = _T>, 137 component: &wasmtime::component::Component, 138 linker: &wasmtime::component::Linker<_T>, 139 ) -> wasmtime::Result<TheWorld> 140 where 141 _T: Send + 'static, 142 { 143 let pre = linker.instantiate_pre(component)?; 144 TheWorldPre::new(pre)?.instantiate_async(store).await 145 } 146 /// Convenience wrapper around [`TheWorldIndices::new`] and 147 /// [`TheWorldIndices::load`]. 148 pub fn new( 149 mut store: impl wasmtime::AsContextMut, 150 instance: &wasmtime::component::Instance, 151 ) -> wasmtime::Result<TheWorld> { 152 let indices = TheWorldIndices::new(&instance.instance_pre(&store))?; 153 indices.load(&mut store, instance) 154 } 155 pub fn add_to_linker<T, U>( 156 linker: &mut wasmtime::component::Linker<T>, 157 get: impl Fn(&mut T) -> &mut U + Send + Sync + Copy + 'static, 158 ) -> wasmtime::Result<()> 159 where 160 T: Send + foo::foo::simple::Host<Data = T> + 'static, 161 U: Send + foo::foo::simple::Host<Data = T>, 162 { 163 foo::foo::simple::add_to_linker(linker, get)?; 164 Ok(()) 165 } 166 pub fn foo_foo_simple(&self) -> &exports::foo::foo::simple::Guest { 167 &self.interface0 168 } 169 } 170 }; 171 pub mod foo { 172 pub mod foo { 173 #[allow(clippy::all)] 174 pub mod simple { 175 #[allow(unused_imports)] 176 use wasmtime::component::__internal::{anyhow, Box}; 177 pub trait Host { 178 type Data; 179 fn f1( 180 store: wasmtime::StoreContextMut<'_, Self::Data>, 181 ) -> impl ::core::future::Future< 182 Output = impl FnOnce( 183 wasmtime::StoreContextMut<'_, Self::Data>, 184 ) -> () + Send + Sync + 'static, 185 > + Send + Sync + 'static 186 where 187 Self: Sized; 188 fn f2( 189 store: wasmtime::StoreContextMut<'_, Self::Data>, 190 a: u32, 191 ) -> impl ::core::future::Future< 192 Output = impl FnOnce( 193 wasmtime::StoreContextMut<'_, Self::Data>, 194 ) -> () + Send + Sync + 'static, 195 > + Send + Sync + 'static 196 where 197 Self: Sized; 198 fn f3( 199 store: wasmtime::StoreContextMut<'_, Self::Data>, 200 a: u32, 201 b: u32, 202 ) -> impl ::core::future::Future< 203 Output = impl FnOnce( 204 wasmtime::StoreContextMut<'_, Self::Data>, 205 ) -> () + Send + Sync + 'static, 206 > + Send + Sync + 'static 207 where 208 Self: Sized; 209 fn f4( 210 store: wasmtime::StoreContextMut<'_, Self::Data>, 211 ) -> impl ::core::future::Future< 212 Output = impl FnOnce( 213 wasmtime::StoreContextMut<'_, Self::Data>, 214 ) -> u32 + Send + Sync + 'static, 215 > + Send + Sync + 'static 216 where 217 Self: Sized; 218 fn f5( 219 store: wasmtime::StoreContextMut<'_, Self::Data>, 220 ) -> impl ::core::future::Future< 221 Output = impl FnOnce( 222 wasmtime::StoreContextMut<'_, Self::Data>, 223 ) -> (u32, u32) + Send + Sync + 'static, 224 > + Send + Sync + 'static 225 where 226 Self: Sized; 227 fn f6( 228 store: wasmtime::StoreContextMut<'_, Self::Data>, 229 a: u32, 230 b: u32, 231 c: u32, 232 ) -> impl ::core::future::Future< 233 Output = impl FnOnce( 234 wasmtime::StoreContextMut<'_, Self::Data>, 235 ) -> (u32, u32, u32) + Send + Sync + 'static, 236 > + Send + Sync + 'static 237 where 238 Self: Sized; 239 } 240 pub trait GetHost< 241 T, 242 D, 243 >: Fn(T) -> <Self as GetHost<T, D>>::Host + Send + Sync + Copy + 'static { 244 type Host: Host<Data = D> + Send; 245 } 246 impl<F, T, D, O> GetHost<T, D> for F 247 where 248 F: Fn(T) -> O + Send + Sync + Copy + 'static, 249 O: Host<Data = D> + Send, 250 { 251 type Host = O; 252 } 253 pub fn add_to_linker_get_host< 254 T, 255 G: for<'a> GetHost<&'a mut T, T, Host: Host<Data = T> + Send>, 256 >( 257 linker: &mut wasmtime::component::Linker<T>, 258 host_getter: G, 259 ) -> wasmtime::Result<()> 260 where 261 T: Send + 'static, 262 { 263 let mut inst = linker.instance("foo:foo/simple")?; 264 inst.func_wrap_concurrent( 265 "f1", 266 move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| { 267 let host = caller; 268 let r = <G::Host as Host>::f1(host); 269 Box::pin(async move { 270 let fun = r.await; 271 Box::new(move |mut caller: wasmtime::StoreContextMut<'_, T>| { 272 let r = fun(caller); 273 Ok(r) 274 }) 275 as Box< 276 dyn FnOnce( 277 wasmtime::StoreContextMut<'_, T>, 278 ) -> wasmtime::Result<()> + Send + Sync, 279 > 280 }) 281 as ::core::pin::Pin< 282 Box< 283 dyn ::core::future::Future< 284 Output = Box< 285 dyn FnOnce( 286 wasmtime::StoreContextMut<'_, T>, 287 ) -> wasmtime::Result<()> + Send + Sync, 288 >, 289 > + Send + Sync + 'static, 290 >, 291 > 292 }, 293 )?; 294 inst.func_wrap_concurrent( 295 "f2", 296 move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (u32,)| { 297 let host = caller; 298 let r = <G::Host as Host>::f2(host, arg0); 299 Box::pin(async move { 300 let fun = r.await; 301 Box::new(move |mut caller: wasmtime::StoreContextMut<'_, T>| { 302 let r = fun(caller); 303 Ok(r) 304 }) 305 as Box< 306 dyn FnOnce( 307 wasmtime::StoreContextMut<'_, T>, 308 ) -> wasmtime::Result<()> + Send + Sync, 309 > 310 }) 311 as ::core::pin::Pin< 312 Box< 313 dyn ::core::future::Future< 314 Output = Box< 315 dyn FnOnce( 316 wasmtime::StoreContextMut<'_, T>, 317 ) -> wasmtime::Result<()> + Send + Sync, 318 >, 319 > + Send + Sync + 'static, 320 >, 321 > 322 }, 323 )?; 324 inst.func_wrap_concurrent( 325 "f3", 326 move | 327 mut caller: wasmtime::StoreContextMut<'_, T>, 328 (arg0, arg1): (u32, u32)| 329 { 330 let host = caller; 331 let r = <G::Host as Host>::f3(host, arg0, arg1); 332 Box::pin(async move { 333 let fun = r.await; 334 Box::new(move |mut caller: wasmtime::StoreContextMut<'_, T>| { 335 let r = fun(caller); 336 Ok(r) 337 }) 338 as Box< 339 dyn FnOnce( 340 wasmtime::StoreContextMut<'_, T>, 341 ) -> wasmtime::Result<()> + Send + Sync, 342 > 343 }) 344 as ::core::pin::Pin< 345 Box< 346 dyn ::core::future::Future< 347 Output = Box< 348 dyn FnOnce( 349 wasmtime::StoreContextMut<'_, T>, 350 ) -> wasmtime::Result<()> + Send + Sync, 351 >, 352 > + Send + Sync + 'static, 353 >, 354 > 355 }, 356 )?; 357 inst.func_wrap_concurrent( 358 "f4", 359 move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| { 360 let host = caller; 361 let r = <G::Host as Host>::f4(host); 362 Box::pin(async move { 363 let fun = r.await; 364 Box::new(move |mut caller: wasmtime::StoreContextMut<'_, T>| { 365 let r = fun(caller); 366 Ok((r,)) 367 }) 368 as Box< 369 dyn FnOnce( 370 wasmtime::StoreContextMut<'_, T>, 371 ) -> wasmtime::Result<(u32,)> + Send + Sync, 372 > 373 }) 374 as ::core::pin::Pin< 375 Box< 376 dyn ::core::future::Future< 377 Output = Box< 378 dyn FnOnce( 379 wasmtime::StoreContextMut<'_, T>, 380 ) -> wasmtime::Result<(u32,)> + Send + Sync, 381 >, 382 > + Send + Sync + 'static, 383 >, 384 > 385 }, 386 )?; 387 inst.func_wrap_concurrent( 388 "f5", 389 move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| { 390 let host = caller; 391 let r = <G::Host as Host>::f5(host); 392 Box::pin(async move { 393 let fun = r.await; 394 Box::new(move |mut caller: wasmtime::StoreContextMut<'_, T>| { 395 let r = fun(caller); 396 Ok((r,)) 397 }) 398 as Box< 399 dyn FnOnce( 400 wasmtime::StoreContextMut<'_, T>, 401 ) -> wasmtime::Result<((u32, u32),)> + Send + Sync, 402 > 403 }) 404 as ::core::pin::Pin< 405 Box< 406 dyn ::core::future::Future< 407 Output = Box< 408 dyn FnOnce( 409 wasmtime::StoreContextMut<'_, T>, 410 ) -> wasmtime::Result<((u32, u32),)> + Send + Sync, 411 >, 412 > + Send + Sync + 'static, 413 >, 414 > 415 }, 416 )?; 417 inst.func_wrap_concurrent( 418 "f6", 419 move | 420 mut caller: wasmtime::StoreContextMut<'_, T>, 421 (arg0, arg1, arg2): (u32, u32, u32)| 422 { 423 let host = caller; 424 let r = <G::Host as Host>::f6(host, arg0, arg1, arg2); 425 Box::pin(async move { 426 let fun = r.await; 427 Box::new(move |mut caller: wasmtime::StoreContextMut<'_, T>| { 428 let r = fun(caller); 429 Ok((r,)) 430 }) 431 as Box< 432 dyn FnOnce( 433 wasmtime::StoreContextMut<'_, T>, 434 ) -> wasmtime::Result<((u32, u32, u32),)> + Send + Sync, 435 > 436 }) 437 as ::core::pin::Pin< 438 Box< 439 dyn ::core::future::Future< 440 Output = Box< 441 dyn FnOnce( 442 wasmtime::StoreContextMut<'_, T>, 443 ) -> wasmtime::Result<((u32, u32, u32),)> + Send + Sync, 444 >, 445 > + Send + Sync + 'static, 446 >, 447 > 448 }, 449 )?; 450 Ok(()) 451 } 452 pub fn add_to_linker<T, U>( 453 linker: &mut wasmtime::component::Linker<T>, 454 get: impl Fn(&mut T) -> &mut U + Send + Sync + Copy + 'static, 455 ) -> wasmtime::Result<()> 456 where 457 U: Host<Data = T> + Send, 458 T: Send + 'static, 459 { 460 add_to_linker_get_host(linker, get) 461 } 462 impl<_T: Host> Host for &mut _T { 463 type Data = _T::Data; 464 fn f1( 465 store: wasmtime::StoreContextMut<'_, Self::Data>, 466 ) -> impl ::core::future::Future< 467 Output = impl FnOnce( 468 wasmtime::StoreContextMut<'_, Self::Data>, 469 ) -> () + Send + Sync + 'static, 470 > + Send + Sync + 'static 471 where 472 Self: Sized, 473 { 474 <_T as Host>::f1(store) 475 } 476 fn f2( 477 store: wasmtime::StoreContextMut<'_, Self::Data>, 478 a: u32, 479 ) -> impl ::core::future::Future< 480 Output = impl FnOnce( 481 wasmtime::StoreContextMut<'_, Self::Data>, 482 ) -> () + Send + Sync + 'static, 483 > + Send + Sync + 'static 484 where 485 Self: Sized, 486 { 487 <_T as Host>::f2(store, a) 488 } 489 fn f3( 490 store: wasmtime::StoreContextMut<'_, Self::Data>, 491 a: u32, 492 b: u32, 493 ) -> impl ::core::future::Future< 494 Output = impl FnOnce( 495 wasmtime::StoreContextMut<'_, Self::Data>, 496 ) -> () + Send + Sync + 'static, 497 > + Send + Sync + 'static 498 where 499 Self: Sized, 500 { 501 <_T as Host>::f3(store, a, b) 502 } 503 fn f4( 504 store: wasmtime::StoreContextMut<'_, Self::Data>, 505 ) -> impl ::core::future::Future< 506 Output = impl FnOnce( 507 wasmtime::StoreContextMut<'_, Self::Data>, 508 ) -> u32 + Send + Sync + 'static, 509 > + Send + Sync + 'static 510 where 511 Self: Sized, 512 { 513 <_T as Host>::f4(store) 514 } 515 fn f5( 516 store: wasmtime::StoreContextMut<'_, Self::Data>, 517 ) -> impl ::core::future::Future< 518 Output = impl FnOnce( 519 wasmtime::StoreContextMut<'_, Self::Data>, 520 ) -> (u32, u32) + Send + Sync + 'static, 521 > + Send + Sync + 'static 522 where 523 Self: Sized, 524 { 525 <_T as Host>::f5(store) 526 } 527 fn f6( 528 store: wasmtime::StoreContextMut<'_, Self::Data>, 529 a: u32, 530 b: u32, 531 c: u32, 532 ) -> impl ::core::future::Future< 533 Output = impl FnOnce( 534 wasmtime::StoreContextMut<'_, Self::Data>, 535 ) -> (u32, u32, u32) + Send + Sync + 'static, 536 > + Send + Sync + 'static 537 where 538 Self: Sized, 539 { 540 <_T as Host>::f6(store, a, b, c) 541 } 542 } 543 } 544 } 545 } 546 pub mod exports { 547 pub mod foo { 548 pub mod foo { 549 #[allow(clippy::all)] 550 pub mod simple { 551 #[allow(unused_imports)] 552 use wasmtime::component::__internal::{anyhow, Box}; 553 pub struct Guest { 554 f1: wasmtime::component::Func, 555 f2: wasmtime::component::Func, 556 f3: wasmtime::component::Func, 557 f4: wasmtime::component::Func, 558 f5: wasmtime::component::Func, 559 f6: wasmtime::component::Func, 560 } 561 #[derive(Clone)] 562 pub struct GuestIndices { 563 f1: wasmtime::component::ComponentExportIndex, 564 f2: wasmtime::component::ComponentExportIndex, 565 f3: wasmtime::component::ComponentExportIndex, 566 f4: wasmtime::component::ComponentExportIndex, 567 f5: wasmtime::component::ComponentExportIndex, 568 f6: wasmtime::component::ComponentExportIndex, 569 } 570 impl GuestIndices { 571 /// Constructor for [`GuestIndices`] which takes a 572 /// [`Component`](wasmtime::component::Component) as input and can be executed 573 /// before instantiation. 574 /// 575 /// This constructor can be used to front-load string lookups to find exports 576 /// within a component. 577 pub fn new<_T>( 578 _instance_pre: &wasmtime::component::InstancePre<_T>, 579 ) -> wasmtime::Result<GuestIndices> { 580 let instance = _instance_pre 581 .component() 582 .get_export_index(None, "foo:foo/simple") 583 .ok_or_else(|| { 584 anyhow::anyhow!( 585 "no exported instance named `foo:foo/simple`" 586 ) 587 })?; 588 let mut lookup = move |name| { 589 _instance_pre 590 .component() 591 .get_export_index(Some(&instance), name) 592 .ok_or_else(|| { 593 anyhow::anyhow!( 594 "instance export `foo:foo/simple` does \ 595 not have export `{name}`" 596 ) 597 }) 598 }; 599 let _ = &mut lookup; 600 let f1 = lookup("f1")?; 601 let f2 = lookup("f2")?; 602 let f3 = lookup("f3")?; 603 let f4 = lookup("f4")?; 604 let f5 = lookup("f5")?; 605 let f6 = lookup("f6")?; 606 Ok(GuestIndices { 607 f1, 608 f2, 609 f3, 610 f4, 611 f5, 612 f6, 613 }) 614 } 615 pub fn load( 616 &self, 617 mut store: impl wasmtime::AsContextMut, 618 instance: &wasmtime::component::Instance, 619 ) -> wasmtime::Result<Guest> { 620 let _instance = instance; 621 let _instance_pre = _instance.instance_pre(&store); 622 let _instance_type = _instance_pre.instance_type(); 623 let mut store = store.as_context_mut(); 624 let _ = &mut store; 625 let f1 = *_instance 626 .get_typed_func::<(), ()>(&mut store, &self.f1)? 627 .func(); 628 let f2 = *_instance 629 .get_typed_func::<(u32,), ()>(&mut store, &self.f2)? 630 .func(); 631 let f3 = *_instance 632 .get_typed_func::<(u32, u32), ()>(&mut store, &self.f3)? 633 .func(); 634 let f4 = *_instance 635 .get_typed_func::<(), (u32,)>(&mut store, &self.f4)? 636 .func(); 637 let f5 = *_instance 638 .get_typed_func::<(), ((u32, u32),)>(&mut store, &self.f5)? 639 .func(); 640 let f6 = *_instance 641 .get_typed_func::< 642 (u32, u32, u32), 643 ((u32, u32, u32),), 644 >(&mut store, &self.f6)? 645 .func(); 646 Ok(Guest { f1, f2, f3, f4, f5, f6 }) 647 } 648 } 649 impl Guest { 650 pub async fn call_f1<S: wasmtime::AsContextMut>( 651 &self, 652 mut store: S, 653 ) -> wasmtime::Result<wasmtime::component::Promise<()>> 654 where 655 <S as wasmtime::AsContext>::Data: Send + 'static, 656 { 657 let callee = unsafe { 658 wasmtime::component::TypedFunc::< 659 (), 660 (), 661 >::new_unchecked(self.f1) 662 }; 663 let promise = callee 664 .call_concurrent(store.as_context_mut(), ()) 665 .await?; 666 Ok(promise) 667 } 668 pub async fn call_f2<S: wasmtime::AsContextMut>( 669 &self, 670 mut store: S, 671 arg0: u32, 672 ) -> wasmtime::Result<wasmtime::component::Promise<()>> 673 where 674 <S as wasmtime::AsContext>::Data: Send + 'static, 675 { 676 let callee = unsafe { 677 wasmtime::component::TypedFunc::< 678 (u32,), 679 (), 680 >::new_unchecked(self.f2) 681 }; 682 let promise = callee 683 .call_concurrent(store.as_context_mut(), (arg0,)) 684 .await?; 685 Ok(promise) 686 } 687 pub async fn call_f3<S: wasmtime::AsContextMut>( 688 &self, 689 mut store: S, 690 arg0: u32, 691 arg1: u32, 692 ) -> wasmtime::Result<wasmtime::component::Promise<()>> 693 where 694 <S as wasmtime::AsContext>::Data: Send + 'static, 695 { 696 let callee = unsafe { 697 wasmtime::component::TypedFunc::< 698 (u32, u32), 699 (), 700 >::new_unchecked(self.f3) 701 }; 702 let promise = callee 703 .call_concurrent(store.as_context_mut(), (arg0, arg1)) 704 .await?; 705 Ok(promise) 706 } 707 pub async fn call_f4<S: wasmtime::AsContextMut>( 708 &self, 709 mut store: S, 710 ) -> wasmtime::Result<wasmtime::component::Promise<u32>> 711 where 712 <S as wasmtime::AsContext>::Data: Send + 'static, 713 { 714 let callee = unsafe { 715 wasmtime::component::TypedFunc::< 716 (), 717 (u32,), 718 >::new_unchecked(self.f4) 719 }; 720 let promise = callee 721 .call_concurrent(store.as_context_mut(), ()) 722 .await?; 723 Ok(promise.map(|(v,)| v)) 724 } 725 pub async fn call_f5<S: wasmtime::AsContextMut>( 726 &self, 727 mut store: S, 728 ) -> wasmtime::Result<wasmtime::component::Promise<(u32, u32)>> 729 where 730 <S as wasmtime::AsContext>::Data: Send + 'static, 731 { 732 let callee = unsafe { 733 wasmtime::component::TypedFunc::< 734 (), 735 ((u32, u32),), 736 >::new_unchecked(self.f5) 737 }; 738 let promise = callee 739 .call_concurrent(store.as_context_mut(), ()) 740 .await?; 741 Ok(promise.map(|(v,)| v)) 742 } 743 pub async fn call_f6<S: wasmtime::AsContextMut>( 744 &self, 745 mut store: S, 746 arg0: u32, 747 arg1: u32, 748 arg2: u32, 749 ) -> wasmtime::Result<wasmtime::component::Promise<(u32, u32, u32)>> 750 where 751 <S as wasmtime::AsContext>::Data: Send + 'static, 752 { 753 let callee = unsafe { 754 wasmtime::component::TypedFunc::< 755 (u32, u32, u32), 756 ((u32, u32, u32),), 757 >::new_unchecked(self.f6) 758 }; 759 let promise = callee 760 .call_concurrent(store.as_context_mut(), (arg0, arg1, arg2)) 761 .await?; 762 Ok(promise.map(|(v,)| v)) 763 } 764 } 765 } 766 } 767 } 768 } 769