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