1 /// Auto-generated bindings for a pre-instantiated version of a
2 /// component which implements the world `the-flags`.
3 ///
4 /// This structure is created through [`TheFlagsPre::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 [`TheFlags`] as well.
9 pub struct TheFlagsPre<T: 'static> {
10     instance_pre: wasmtime::component::InstancePre<T>,
11     indices: TheFlagsIndices,
12 }
13 impl<T: 'static> Clone for TheFlagsPre<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: 'static> TheFlagsPre<_T> {
22     /// Creates a new copy of `TheFlagsPre` 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 = TheFlagsIndices::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 [`TheFlags`] 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<TheFlags>
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-flags`.
60 ///
61 /// This is an implementation detail of [`TheFlagsPre`] and can
62 /// be constructed if needed as well.
63 ///
64 /// For more information see [`TheFlags`] as well.
65 #[derive(Clone)]
66 pub struct TheFlagsIndices {
67     interface0: exports::foo::foo::flegs::GuestIndices,
68 }
69 /// Auto-generated bindings for an instance a component which
70 /// implements the world `the-flags`.
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 ///   [`TheFlags::instantiate_async`] which only needs a
77 ///   [`Store`], [`Component`], and [`Linker`].
78 ///
79 /// * Alternatively you can create a [`TheFlagsPre`] 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 [`TheFlagsPre::instantiate_async`] to
83 ///   create a [`TheFlags`].
84 ///
85 /// * If you've instantiated the instance yourself already
86 ///   then you can use [`TheFlags::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 TheFlags {
95     interface0: exports::foo::foo::flegs::Guest,
96 }
97 const _: () = {
98     #[allow(unused_imports)]
99     use wasmtime::component::__internal::anyhow;
100     impl TheFlagsIndices {
101         /// Creates a new copy of `TheFlagsIndices` 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::flegs::GuestIndices::new(_instance_pre)?;
112             Ok(TheFlagsIndices { interface0 })
113         }
114         /// Uses the indices stored in `self` to load an instance
115         /// of [`TheFlags`] from the instance provided.
116         ///
117         /// Note that at this time this method will additionally
118         /// perform type-checks of all exports.
119         pub fn load(
120             &self,
121             mut store: impl wasmtime::AsContextMut,
122             instance: &wasmtime::component::Instance,
123         ) -> wasmtime::Result<TheFlags> {
124             let _ = &mut store;
125             let _instance = instance;
126             let interface0 = self.interface0.load(&mut store, &_instance)?;
127             Ok(TheFlags { interface0 })
128         }
129     }
130     impl TheFlags {
131         /// Convenience wrapper around [`TheFlagsPre::new`] and
132         /// [`TheFlagsPre::instantiate_async`].
133         pub async fn instantiate_async<_T>(
134             store: impl wasmtime::AsContextMut<Data = _T>,
135             component: &wasmtime::component::Component,
136             linker: &wasmtime::component::Linker<_T>,
137         ) -> wasmtime::Result<TheFlags>
138         where
139             _T: Send + 'static,
140         {
141             let pre = linker.instantiate_pre(component)?;
142             TheFlagsPre::new(pre)?.instantiate_async(store).await
143         }
144         /// Convenience wrapper around [`TheFlagsIndices::new`] and
145         /// [`TheFlagsIndices::load`].
146         pub fn new(
147             mut store: impl wasmtime::AsContextMut,
148             instance: &wasmtime::component::Instance,
149         ) -> wasmtime::Result<TheFlags> {
150             let indices = TheFlagsIndices::new(&instance.instance_pre(&store))?;
151             indices.load(&mut store, instance)
152         }
153         pub fn add_to_linker<T, U>(
154             linker: &mut wasmtime::component::Linker<T>,
155             get: impl Fn(&mut T) -> &mut U + Send + Sync + Copy + 'static,
156         ) -> wasmtime::Result<()>
157         where
158             T: 'static,
159             T: Send + foo::foo::flegs::Host<Data = T>,
160             U: Send + foo::foo::flegs::Host<Data = T>,
161         {
162             foo::foo::flegs::add_to_linker(linker, get)?;
163             Ok(())
164         }
165         pub fn foo_foo_flegs(&self) -> &exports::foo::foo::flegs::Guest {
166             &self.interface0
167         }
168     }
169 };
170 pub mod foo {
171     pub mod foo {
172         #[allow(clippy::all)]
173         pub mod flegs {
174             #[allow(unused_imports)]
175             use wasmtime::component::__internal::{anyhow, Box};
176             wasmtime::component::flags!(Flag1 { #[component(name = "b0")] const B0; });
177             const _: () = {
178                 assert!(1 == < Flag1 as wasmtime::component::ComponentType >::SIZE32);
179                 assert!(1 == < Flag1 as wasmtime::component::ComponentType >::ALIGN32);
180             };
181             wasmtime::component::flags!(
182                 Flag2 { #[component(name = "b0")] const B0; #[component(name = "b1")]
183                 const B1; }
184             );
185             const _: () = {
186                 assert!(1 == < Flag2 as wasmtime::component::ComponentType >::SIZE32);
187                 assert!(1 == < Flag2 as wasmtime::component::ComponentType >::ALIGN32);
188             };
189             wasmtime::component::flags!(
190                 Flag4 { #[component(name = "b0")] const B0; #[component(name = "b1")]
191                 const B1; #[component(name = "b2")] const B2; #[component(name = "b3")]
192                 const B3; }
193             );
194             const _: () = {
195                 assert!(1 == < Flag4 as wasmtime::component::ComponentType >::SIZE32);
196                 assert!(1 == < Flag4 as wasmtime::component::ComponentType >::ALIGN32);
197             };
198             wasmtime::component::flags!(
199                 Flag8 { #[component(name = "b0")] const B0; #[component(name = "b1")]
200                 const B1; #[component(name = "b2")] const B2; #[component(name = "b3")]
201                 const B3; #[component(name = "b4")] const B4; #[component(name = "b5")]
202                 const B5; #[component(name = "b6")] const B6; #[component(name = "b7")]
203                 const B7; }
204             );
205             const _: () = {
206                 assert!(1 == < Flag8 as wasmtime::component::ComponentType >::SIZE32);
207                 assert!(1 == < Flag8 as wasmtime::component::ComponentType >::ALIGN32);
208             };
209             wasmtime::component::flags!(
210                 Flag16 { #[component(name = "b0")] const B0; #[component(name = "b1")]
211                 const B1; #[component(name = "b2")] const B2; #[component(name = "b3")]
212                 const B3; #[component(name = "b4")] const B4; #[component(name = "b5")]
213                 const B5; #[component(name = "b6")] const B6; #[component(name = "b7")]
214                 const B7; #[component(name = "b8")] const B8; #[component(name = "b9")]
215                 const B9; #[component(name = "b10")] const B10; #[component(name =
216                 "b11")] const B11; #[component(name = "b12")] const B12; #[component(name
217                 = "b13")] const B13; #[component(name = "b14")] const B14;
218                 #[component(name = "b15")] const B15; }
219             );
220             const _: () = {
221                 assert!(2 == < Flag16 as wasmtime::component::ComponentType >::SIZE32);
222                 assert!(2 == < Flag16 as wasmtime::component::ComponentType >::ALIGN32);
223             };
224             wasmtime::component::flags!(
225                 Flag32 { #[component(name = "b0")] const B0; #[component(name = "b1")]
226                 const B1; #[component(name = "b2")] const B2; #[component(name = "b3")]
227                 const B3; #[component(name = "b4")] const B4; #[component(name = "b5")]
228                 const B5; #[component(name = "b6")] const B6; #[component(name = "b7")]
229                 const B7; #[component(name = "b8")] const B8; #[component(name = "b9")]
230                 const B9; #[component(name = "b10")] const B10; #[component(name =
231                 "b11")] const B11; #[component(name = "b12")] const B12; #[component(name
232                 = "b13")] const B13; #[component(name = "b14")] const B14;
233                 #[component(name = "b15")] const B15; #[component(name = "b16")] const
234                 B16; #[component(name = "b17")] const B17; #[component(name = "b18")]
235                 const B18; #[component(name = "b19")] const B19; #[component(name =
236                 "b20")] const B20; #[component(name = "b21")] const B21; #[component(name
237                 = "b22")] const B22; #[component(name = "b23")] const B23;
238                 #[component(name = "b24")] const B24; #[component(name = "b25")] const
239                 B25; #[component(name = "b26")] const B26; #[component(name = "b27")]
240                 const B27; #[component(name = "b28")] const B28; #[component(name =
241                 "b29")] const B29; #[component(name = "b30")] const B30; #[component(name
242                 = "b31")] const B31; }
243             );
244             const _: () = {
245                 assert!(4 == < Flag32 as wasmtime::component::ComponentType >::SIZE32);
246                 assert!(4 == < Flag32 as wasmtime::component::ComponentType >::ALIGN32);
247             };
248             wasmtime::component::flags!(
249                 Flag64 { #[component(name = "b0")] const B0; #[component(name = "b1")]
250                 const B1; #[component(name = "b2")] const B2; #[component(name = "b3")]
251                 const B3; #[component(name = "b4")] const B4; #[component(name = "b5")]
252                 const B5; #[component(name = "b6")] const B6; #[component(name = "b7")]
253                 const B7; #[component(name = "b8")] const B8; #[component(name = "b9")]
254                 const B9; #[component(name = "b10")] const B10; #[component(name =
255                 "b11")] const B11; #[component(name = "b12")] const B12; #[component(name
256                 = "b13")] const B13; #[component(name = "b14")] const B14;
257                 #[component(name = "b15")] const B15; #[component(name = "b16")] const
258                 B16; #[component(name = "b17")] const B17; #[component(name = "b18")]
259                 const B18; #[component(name = "b19")] const B19; #[component(name =
260                 "b20")] const B20; #[component(name = "b21")] const B21; #[component(name
261                 = "b22")] const B22; #[component(name = "b23")] const B23;
262                 #[component(name = "b24")] const B24; #[component(name = "b25")] const
263                 B25; #[component(name = "b26")] const B26; #[component(name = "b27")]
264                 const B27; #[component(name = "b28")] const B28; #[component(name =
265                 "b29")] const B29; #[component(name = "b30")] const B30; #[component(name
266                 = "b31")] const B31; #[component(name = "b32")] const B32;
267                 #[component(name = "b33")] const B33; #[component(name = "b34")] const
268                 B34; #[component(name = "b35")] const B35; #[component(name = "b36")]
269                 const B36; #[component(name = "b37")] const B37; #[component(name =
270                 "b38")] const B38; #[component(name = "b39")] const B39; #[component(name
271                 = "b40")] const B40; #[component(name = "b41")] const B41;
272                 #[component(name = "b42")] const B42; #[component(name = "b43")] const
273                 B43; #[component(name = "b44")] const B44; #[component(name = "b45")]
274                 const B45; #[component(name = "b46")] const B46; #[component(name =
275                 "b47")] const B47; #[component(name = "b48")] const B48; #[component(name
276                 = "b49")] const B49; #[component(name = "b50")] const B50;
277                 #[component(name = "b51")] const B51; #[component(name = "b52")] const
278                 B52; #[component(name = "b53")] const B53; #[component(name = "b54")]
279                 const B54; #[component(name = "b55")] const B55; #[component(name =
280                 "b56")] const B56; #[component(name = "b57")] const B57; #[component(name
281                 = "b58")] const B58; #[component(name = "b59")] const B59;
282                 #[component(name = "b60")] const B60; #[component(name = "b61")] const
283                 B61; #[component(name = "b62")] const B62; #[component(name = "b63")]
284                 const B63; }
285             );
286             const _: () = {
287                 assert!(8 == < Flag64 as wasmtime::component::ComponentType >::SIZE32);
288                 assert!(4 == < Flag64 as wasmtime::component::ComponentType >::ALIGN32);
289             };
290             pub trait Host {
291                 type Data;
292                 fn roundtrip_flag1(
293                     store: wasmtime::StoreContextMut<'_, Self::Data>,
294                     x: Flag1,
295                 ) -> impl ::core::future::Future<
296                     Output = impl FnOnce(
297                         wasmtime::StoreContextMut<'_, Self::Data>,
298                     ) -> Flag1 + Send + Sync + 'static,
299                 > + Send + Sync + 'static
300                 where
301                     Self: Sized;
302                 fn roundtrip_flag2(
303                     store: wasmtime::StoreContextMut<'_, Self::Data>,
304                     x: Flag2,
305                 ) -> impl ::core::future::Future<
306                     Output = impl FnOnce(
307                         wasmtime::StoreContextMut<'_, Self::Data>,
308                     ) -> Flag2 + Send + Sync + 'static,
309                 > + Send + Sync + 'static
310                 where
311                     Self: Sized;
312                 fn roundtrip_flag4(
313                     store: wasmtime::StoreContextMut<'_, Self::Data>,
314                     x: Flag4,
315                 ) -> impl ::core::future::Future<
316                     Output = impl FnOnce(
317                         wasmtime::StoreContextMut<'_, Self::Data>,
318                     ) -> Flag4 + Send + Sync + 'static,
319                 > + Send + Sync + 'static
320                 where
321                     Self: Sized;
322                 fn roundtrip_flag8(
323                     store: wasmtime::StoreContextMut<'_, Self::Data>,
324                     x: Flag8,
325                 ) -> impl ::core::future::Future<
326                     Output = impl FnOnce(
327                         wasmtime::StoreContextMut<'_, Self::Data>,
328                     ) -> Flag8 + Send + Sync + 'static,
329                 > + Send + Sync + 'static
330                 where
331                     Self: Sized;
332                 fn roundtrip_flag16(
333                     store: wasmtime::StoreContextMut<'_, Self::Data>,
334                     x: Flag16,
335                 ) -> impl ::core::future::Future<
336                     Output = impl FnOnce(
337                         wasmtime::StoreContextMut<'_, Self::Data>,
338                     ) -> Flag16 + Send + Sync + 'static,
339                 > + Send + Sync + 'static
340                 where
341                     Self: Sized;
342                 fn roundtrip_flag32(
343                     store: wasmtime::StoreContextMut<'_, Self::Data>,
344                     x: Flag32,
345                 ) -> impl ::core::future::Future<
346                     Output = impl FnOnce(
347                         wasmtime::StoreContextMut<'_, Self::Data>,
348                     ) -> Flag32 + Send + Sync + 'static,
349                 > + Send + Sync + 'static
350                 where
351                     Self: Sized;
352                 fn roundtrip_flag64(
353                     store: wasmtime::StoreContextMut<'_, Self::Data>,
354                     x: Flag64,
355                 ) -> impl ::core::future::Future<
356                     Output = impl FnOnce(
357                         wasmtime::StoreContextMut<'_, Self::Data>,
358                     ) -> Flag64 + Send + Sync + 'static,
359                 > + Send + Sync + 'static
360                 where
361                     Self: Sized;
362             }
363             pub fn add_to_linker_get_host<T, G>(
364                 linker: &mut wasmtime::component::Linker<T>,
365                 host_getter: G,
366             ) -> wasmtime::Result<()>
367             where
368                 T: 'static,
369                 G: for<'a> wasmtime::component::GetHost<
370                     &'a mut T,
371                     Host: Host<Data = T> + Send,
372                 >,
373                 T: Send + 'static,
374             {
375                 let mut inst = linker.instance("foo:foo/flegs")?;
376                 inst.func_wrap_concurrent(
377                     "roundtrip-flag1",
378                     move |
379                         mut caller: wasmtime::StoreContextMut<'_, T>,
380                         (arg0,): (Flag1,)|
381                     {
382                         let host = caller;
383                         let r = <G::Host as Host>::roundtrip_flag1(host, arg0);
384                         Box::pin(async move {
385                             let fun = r.await;
386                             Box::new(move |mut caller: wasmtime::StoreContextMut<'_, T>| {
387                                 let r = fun(caller);
388                                 Ok((r,))
389                             })
390                                 as Box<
391                                     dyn FnOnce(
392                                         wasmtime::StoreContextMut<'_, T>,
393                                     ) -> wasmtime::Result<(Flag1,)> + Send + Sync,
394                                 >
395                         })
396                             as ::core::pin::Pin<
397                                 Box<
398                                     dyn ::core::future::Future<
399                                         Output = Box<
400                                             dyn FnOnce(
401                                                 wasmtime::StoreContextMut<'_, T>,
402                                             ) -> wasmtime::Result<(Flag1,)> + Send + Sync,
403                                         >,
404                                     > + Send + Sync + 'static,
405                                 >,
406                             >
407                     },
408                 )?;
409                 inst.func_wrap_concurrent(
410                     "roundtrip-flag2",
411                     move |
412                         mut caller: wasmtime::StoreContextMut<'_, T>,
413                         (arg0,): (Flag2,)|
414                     {
415                         let host = caller;
416                         let r = <G::Host as Host>::roundtrip_flag2(host, arg0);
417                         Box::pin(async move {
418                             let fun = r.await;
419                             Box::new(move |mut caller: wasmtime::StoreContextMut<'_, T>| {
420                                 let r = fun(caller);
421                                 Ok((r,))
422                             })
423                                 as Box<
424                                     dyn FnOnce(
425                                         wasmtime::StoreContextMut<'_, T>,
426                                     ) -> wasmtime::Result<(Flag2,)> + Send + Sync,
427                                 >
428                         })
429                             as ::core::pin::Pin<
430                                 Box<
431                                     dyn ::core::future::Future<
432                                         Output = Box<
433                                             dyn FnOnce(
434                                                 wasmtime::StoreContextMut<'_, T>,
435                                             ) -> wasmtime::Result<(Flag2,)> + Send + Sync,
436                                         >,
437                                     > + Send + Sync + 'static,
438                                 >,
439                             >
440                     },
441                 )?;
442                 inst.func_wrap_concurrent(
443                     "roundtrip-flag4",
444                     move |
445                         mut caller: wasmtime::StoreContextMut<'_, T>,
446                         (arg0,): (Flag4,)|
447                     {
448                         let host = caller;
449                         let r = <G::Host as Host>::roundtrip_flag4(host, arg0);
450                         Box::pin(async move {
451                             let fun = r.await;
452                             Box::new(move |mut caller: wasmtime::StoreContextMut<'_, T>| {
453                                 let r = fun(caller);
454                                 Ok((r,))
455                             })
456                                 as Box<
457                                     dyn FnOnce(
458                                         wasmtime::StoreContextMut<'_, T>,
459                                     ) -> wasmtime::Result<(Flag4,)> + Send + Sync,
460                                 >
461                         })
462                             as ::core::pin::Pin<
463                                 Box<
464                                     dyn ::core::future::Future<
465                                         Output = Box<
466                                             dyn FnOnce(
467                                                 wasmtime::StoreContextMut<'_, T>,
468                                             ) -> wasmtime::Result<(Flag4,)> + Send + Sync,
469                                         >,
470                                     > + Send + Sync + 'static,
471                                 >,
472                             >
473                     },
474                 )?;
475                 inst.func_wrap_concurrent(
476                     "roundtrip-flag8",
477                     move |
478                         mut caller: wasmtime::StoreContextMut<'_, T>,
479                         (arg0,): (Flag8,)|
480                     {
481                         let host = caller;
482                         let r = <G::Host as Host>::roundtrip_flag8(host, arg0);
483                         Box::pin(async move {
484                             let fun = r.await;
485                             Box::new(move |mut caller: wasmtime::StoreContextMut<'_, T>| {
486                                 let r = fun(caller);
487                                 Ok((r,))
488                             })
489                                 as Box<
490                                     dyn FnOnce(
491                                         wasmtime::StoreContextMut<'_, T>,
492                                     ) -> wasmtime::Result<(Flag8,)> + Send + Sync,
493                                 >
494                         })
495                             as ::core::pin::Pin<
496                                 Box<
497                                     dyn ::core::future::Future<
498                                         Output = Box<
499                                             dyn FnOnce(
500                                                 wasmtime::StoreContextMut<'_, T>,
501                                             ) -> wasmtime::Result<(Flag8,)> + Send + Sync,
502                                         >,
503                                     > + Send + Sync + 'static,
504                                 >,
505                             >
506                     },
507                 )?;
508                 inst.func_wrap_concurrent(
509                     "roundtrip-flag16",
510                     move |
511                         mut caller: wasmtime::StoreContextMut<'_, T>,
512                         (arg0,): (Flag16,)|
513                     {
514                         let host = caller;
515                         let r = <G::Host as Host>::roundtrip_flag16(host, arg0);
516                         Box::pin(async move {
517                             let fun = r.await;
518                             Box::new(move |mut caller: wasmtime::StoreContextMut<'_, T>| {
519                                 let r = fun(caller);
520                                 Ok((r,))
521                             })
522                                 as Box<
523                                     dyn FnOnce(
524                                         wasmtime::StoreContextMut<'_, T>,
525                                     ) -> wasmtime::Result<(Flag16,)> + Send + Sync,
526                                 >
527                         })
528                             as ::core::pin::Pin<
529                                 Box<
530                                     dyn ::core::future::Future<
531                                         Output = Box<
532                                             dyn FnOnce(
533                                                 wasmtime::StoreContextMut<'_, T>,
534                                             ) -> wasmtime::Result<(Flag16,)> + Send + Sync,
535                                         >,
536                                     > + Send + Sync + 'static,
537                                 >,
538                             >
539                     },
540                 )?;
541                 inst.func_wrap_concurrent(
542                     "roundtrip-flag32",
543                     move |
544                         mut caller: wasmtime::StoreContextMut<'_, T>,
545                         (arg0,): (Flag32,)|
546                     {
547                         let host = caller;
548                         let r = <G::Host as Host>::roundtrip_flag32(host, arg0);
549                         Box::pin(async move {
550                             let fun = r.await;
551                             Box::new(move |mut caller: wasmtime::StoreContextMut<'_, T>| {
552                                 let r = fun(caller);
553                                 Ok((r,))
554                             })
555                                 as Box<
556                                     dyn FnOnce(
557                                         wasmtime::StoreContextMut<'_, T>,
558                                     ) -> wasmtime::Result<(Flag32,)> + Send + Sync,
559                                 >
560                         })
561                             as ::core::pin::Pin<
562                                 Box<
563                                     dyn ::core::future::Future<
564                                         Output = Box<
565                                             dyn FnOnce(
566                                                 wasmtime::StoreContextMut<'_, T>,
567                                             ) -> wasmtime::Result<(Flag32,)> + Send + Sync,
568                                         >,
569                                     > + Send + Sync + 'static,
570                                 >,
571                             >
572                     },
573                 )?;
574                 inst.func_wrap_concurrent(
575                     "roundtrip-flag64",
576                     move |
577                         mut caller: wasmtime::StoreContextMut<'_, T>,
578                         (arg0,): (Flag64,)|
579                     {
580                         let host = caller;
581                         let r = <G::Host as Host>::roundtrip_flag64(host, arg0);
582                         Box::pin(async move {
583                             let fun = r.await;
584                             Box::new(move |mut caller: wasmtime::StoreContextMut<'_, T>| {
585                                 let r = fun(caller);
586                                 Ok((r,))
587                             })
588                                 as Box<
589                                     dyn FnOnce(
590                                         wasmtime::StoreContextMut<'_, T>,
591                                     ) -> wasmtime::Result<(Flag64,)> + Send + Sync,
592                                 >
593                         })
594                             as ::core::pin::Pin<
595                                 Box<
596                                     dyn ::core::future::Future<
597                                         Output = Box<
598                                             dyn FnOnce(
599                                                 wasmtime::StoreContextMut<'_, T>,
600                                             ) -> wasmtime::Result<(Flag64,)> + Send + Sync,
601                                         >,
602                                     > + Send + Sync + 'static,
603                                 >,
604                             >
605                     },
606                 )?;
607                 Ok(())
608             }
609             pub fn add_to_linker<T, U>(
610                 linker: &mut wasmtime::component::Linker<T>,
611                 get: impl Fn(&mut T) -> &mut U + Send + Sync + Copy + 'static,
612             ) -> wasmtime::Result<()>
613             where
614                 T: 'static,
615                 U: Host<Data = T> + Send,
616                 T: Send + 'static,
617             {
618                 add_to_linker_get_host(linker, get)
619             }
620             impl<_T: Host> Host for &mut _T {
621                 type Data = _T::Data;
622                 fn roundtrip_flag1(
623                     store: wasmtime::StoreContextMut<'_, Self::Data>,
624                     x: Flag1,
625                 ) -> impl ::core::future::Future<
626                     Output = impl FnOnce(
627                         wasmtime::StoreContextMut<'_, Self::Data>,
628                     ) -> Flag1 + Send + Sync + 'static,
629                 > + Send + Sync + 'static
630                 where
631                     Self: Sized,
632                 {
633                     <_T as Host>::roundtrip_flag1(store, x)
634                 }
635                 fn roundtrip_flag2(
636                     store: wasmtime::StoreContextMut<'_, Self::Data>,
637                     x: Flag2,
638                 ) -> impl ::core::future::Future<
639                     Output = impl FnOnce(
640                         wasmtime::StoreContextMut<'_, Self::Data>,
641                     ) -> Flag2 + Send + Sync + 'static,
642                 > + Send + Sync + 'static
643                 where
644                     Self: Sized,
645                 {
646                     <_T as Host>::roundtrip_flag2(store, x)
647                 }
648                 fn roundtrip_flag4(
649                     store: wasmtime::StoreContextMut<'_, Self::Data>,
650                     x: Flag4,
651                 ) -> impl ::core::future::Future<
652                     Output = impl FnOnce(
653                         wasmtime::StoreContextMut<'_, Self::Data>,
654                     ) -> Flag4 + Send + Sync + 'static,
655                 > + Send + Sync + 'static
656                 where
657                     Self: Sized,
658                 {
659                     <_T as Host>::roundtrip_flag4(store, x)
660                 }
661                 fn roundtrip_flag8(
662                     store: wasmtime::StoreContextMut<'_, Self::Data>,
663                     x: Flag8,
664                 ) -> impl ::core::future::Future<
665                     Output = impl FnOnce(
666                         wasmtime::StoreContextMut<'_, Self::Data>,
667                     ) -> Flag8 + Send + Sync + 'static,
668                 > + Send + Sync + 'static
669                 where
670                     Self: Sized,
671                 {
672                     <_T as Host>::roundtrip_flag8(store, x)
673                 }
674                 fn roundtrip_flag16(
675                     store: wasmtime::StoreContextMut<'_, Self::Data>,
676                     x: Flag16,
677                 ) -> impl ::core::future::Future<
678                     Output = impl FnOnce(
679                         wasmtime::StoreContextMut<'_, Self::Data>,
680                     ) -> Flag16 + Send + Sync + 'static,
681                 > + Send + Sync + 'static
682                 where
683                     Self: Sized,
684                 {
685                     <_T as Host>::roundtrip_flag16(store, x)
686                 }
687                 fn roundtrip_flag32(
688                     store: wasmtime::StoreContextMut<'_, Self::Data>,
689                     x: Flag32,
690                 ) -> impl ::core::future::Future<
691                     Output = impl FnOnce(
692                         wasmtime::StoreContextMut<'_, Self::Data>,
693                     ) -> Flag32 + Send + Sync + 'static,
694                 > + Send + Sync + 'static
695                 where
696                     Self: Sized,
697                 {
698                     <_T as Host>::roundtrip_flag32(store, x)
699                 }
700                 fn roundtrip_flag64(
701                     store: wasmtime::StoreContextMut<'_, Self::Data>,
702                     x: Flag64,
703                 ) -> impl ::core::future::Future<
704                     Output = impl FnOnce(
705                         wasmtime::StoreContextMut<'_, Self::Data>,
706                     ) -> Flag64 + Send + Sync + 'static,
707                 > + Send + Sync + 'static
708                 where
709                     Self: Sized,
710                 {
711                     <_T as Host>::roundtrip_flag64(store, x)
712                 }
713             }
714         }
715     }
716 }
717 pub mod exports {
718     pub mod foo {
719         pub mod foo {
720             #[allow(clippy::all)]
721             pub mod flegs {
722                 #[allow(unused_imports)]
723                 use wasmtime::component::__internal::{anyhow, Box};
724                 wasmtime::component::flags!(
725                     Flag1 { #[component(name = "b0")] const B0; }
726                 );
727                 const _: () = {
728                     assert!(
729                         1 == < Flag1 as wasmtime::component::ComponentType >::SIZE32
730                     );
731                     assert!(
732                         1 == < Flag1 as wasmtime::component::ComponentType >::ALIGN32
733                     );
734                 };
735                 wasmtime::component::flags!(
736                     Flag2 { #[component(name = "b0")] const B0; #[component(name = "b1")]
737                     const B1; }
738                 );
739                 const _: () = {
740                     assert!(
741                         1 == < Flag2 as wasmtime::component::ComponentType >::SIZE32
742                     );
743                     assert!(
744                         1 == < Flag2 as wasmtime::component::ComponentType >::ALIGN32
745                     );
746                 };
747                 wasmtime::component::flags!(
748                     Flag4 { #[component(name = "b0")] const B0; #[component(name = "b1")]
749                     const B1; #[component(name = "b2")] const B2; #[component(name =
750                     "b3")] const B3; }
751                 );
752                 const _: () = {
753                     assert!(
754                         1 == < Flag4 as wasmtime::component::ComponentType >::SIZE32
755                     );
756                     assert!(
757                         1 == < Flag4 as wasmtime::component::ComponentType >::ALIGN32
758                     );
759                 };
760                 wasmtime::component::flags!(
761                     Flag8 { #[component(name = "b0")] const B0; #[component(name = "b1")]
762                     const B1; #[component(name = "b2")] const B2; #[component(name =
763                     "b3")] const B3; #[component(name = "b4")] const B4; #[component(name
764                     = "b5")] const B5; #[component(name = "b6")] const B6;
765                     #[component(name = "b7")] const B7; }
766                 );
767                 const _: () = {
768                     assert!(
769                         1 == < Flag8 as wasmtime::component::ComponentType >::SIZE32
770                     );
771                     assert!(
772                         1 == < Flag8 as wasmtime::component::ComponentType >::ALIGN32
773                     );
774                 };
775                 wasmtime::component::flags!(
776                     Flag16 { #[component(name = "b0")] const B0; #[component(name =
777                     "b1")] const B1; #[component(name = "b2")] const B2; #[component(name
778                     = "b3")] const B3; #[component(name = "b4")] const B4;
779                     #[component(name = "b5")] const B5; #[component(name = "b6")] const
780                     B6; #[component(name = "b7")] const B7; #[component(name = "b8")]
781                     const B8; #[component(name = "b9")] const B9; #[component(name =
782                     "b10")] const B10; #[component(name = "b11")] const B11;
783                     #[component(name = "b12")] const B12; #[component(name = "b13")]
784                     const B13; #[component(name = "b14")] const B14; #[component(name =
785                     "b15")] const B15; }
786                 );
787                 const _: () = {
788                     assert!(
789                         2 == < Flag16 as wasmtime::component::ComponentType >::SIZE32
790                     );
791                     assert!(
792                         2 == < Flag16 as wasmtime::component::ComponentType >::ALIGN32
793                     );
794                 };
795                 wasmtime::component::flags!(
796                     Flag32 { #[component(name = "b0")] const B0; #[component(name =
797                     "b1")] const B1; #[component(name = "b2")] const B2; #[component(name
798                     = "b3")] const B3; #[component(name = "b4")] const B4;
799                     #[component(name = "b5")] const B5; #[component(name = "b6")] const
800                     B6; #[component(name = "b7")] const B7; #[component(name = "b8")]
801                     const B8; #[component(name = "b9")] const B9; #[component(name =
802                     "b10")] const B10; #[component(name = "b11")] const B11;
803                     #[component(name = "b12")] const B12; #[component(name = "b13")]
804                     const B13; #[component(name = "b14")] const B14; #[component(name =
805                     "b15")] const B15; #[component(name = "b16")] const B16;
806                     #[component(name = "b17")] const B17; #[component(name = "b18")]
807                     const B18; #[component(name = "b19")] const B19; #[component(name =
808                     "b20")] const B20; #[component(name = "b21")] const B21;
809                     #[component(name = "b22")] const B22; #[component(name = "b23")]
810                     const B23; #[component(name = "b24")] const B24; #[component(name =
811                     "b25")] const B25; #[component(name = "b26")] const B26;
812                     #[component(name = "b27")] const B27; #[component(name = "b28")]
813                     const B28; #[component(name = "b29")] const B29; #[component(name =
814                     "b30")] const B30; #[component(name = "b31")] const B31; }
815                 );
816                 const _: () = {
817                     assert!(
818                         4 == < Flag32 as wasmtime::component::ComponentType >::SIZE32
819                     );
820                     assert!(
821                         4 == < Flag32 as wasmtime::component::ComponentType >::ALIGN32
822                     );
823                 };
824                 wasmtime::component::flags!(
825                     Flag64 { #[component(name = "b0")] const B0; #[component(name =
826                     "b1")] const B1; #[component(name = "b2")] const B2; #[component(name
827                     = "b3")] const B3; #[component(name = "b4")] const B4;
828                     #[component(name = "b5")] const B5; #[component(name = "b6")] const
829                     B6; #[component(name = "b7")] const B7; #[component(name = "b8")]
830                     const B8; #[component(name = "b9")] const B9; #[component(name =
831                     "b10")] const B10; #[component(name = "b11")] const B11;
832                     #[component(name = "b12")] const B12; #[component(name = "b13")]
833                     const B13; #[component(name = "b14")] const B14; #[component(name =
834                     "b15")] const B15; #[component(name = "b16")] const B16;
835                     #[component(name = "b17")] const B17; #[component(name = "b18")]
836                     const B18; #[component(name = "b19")] const B19; #[component(name =
837                     "b20")] const B20; #[component(name = "b21")] const B21;
838                     #[component(name = "b22")] const B22; #[component(name = "b23")]
839                     const B23; #[component(name = "b24")] const B24; #[component(name =
840                     "b25")] const B25; #[component(name = "b26")] const B26;
841                     #[component(name = "b27")] const B27; #[component(name = "b28")]
842                     const B28; #[component(name = "b29")] const B29; #[component(name =
843                     "b30")] const B30; #[component(name = "b31")] const B31;
844                     #[component(name = "b32")] const B32; #[component(name = "b33")]
845                     const B33; #[component(name = "b34")] const B34; #[component(name =
846                     "b35")] const B35; #[component(name = "b36")] const B36;
847                     #[component(name = "b37")] const B37; #[component(name = "b38")]
848                     const B38; #[component(name = "b39")] const B39; #[component(name =
849                     "b40")] const B40; #[component(name = "b41")] const B41;
850                     #[component(name = "b42")] const B42; #[component(name = "b43")]
851                     const B43; #[component(name = "b44")] const B44; #[component(name =
852                     "b45")] const B45; #[component(name = "b46")] const B46;
853                     #[component(name = "b47")] const B47; #[component(name = "b48")]
854                     const B48; #[component(name = "b49")] const B49; #[component(name =
855                     "b50")] const B50; #[component(name = "b51")] const B51;
856                     #[component(name = "b52")] const B52; #[component(name = "b53")]
857                     const B53; #[component(name = "b54")] const B54; #[component(name =
858                     "b55")] const B55; #[component(name = "b56")] const B56;
859                     #[component(name = "b57")] const B57; #[component(name = "b58")]
860                     const B58; #[component(name = "b59")] const B59; #[component(name =
861                     "b60")] const B60; #[component(name = "b61")] const B61;
862                     #[component(name = "b62")] const B62; #[component(name = "b63")]
863                     const B63; }
864                 );
865                 const _: () = {
866                     assert!(
867                         8 == < Flag64 as wasmtime::component::ComponentType >::SIZE32
868                     );
869                     assert!(
870                         4 == < Flag64 as wasmtime::component::ComponentType >::ALIGN32
871                     );
872                 };
873                 pub struct Guest {
874                     roundtrip_flag1: wasmtime::component::Func,
875                     roundtrip_flag2: wasmtime::component::Func,
876                     roundtrip_flag4: wasmtime::component::Func,
877                     roundtrip_flag8: wasmtime::component::Func,
878                     roundtrip_flag16: wasmtime::component::Func,
879                     roundtrip_flag32: wasmtime::component::Func,
880                     roundtrip_flag64: wasmtime::component::Func,
881                 }
882                 #[derive(Clone)]
883                 pub struct GuestIndices {
884                     roundtrip_flag1: wasmtime::component::ComponentExportIndex,
885                     roundtrip_flag2: wasmtime::component::ComponentExportIndex,
886                     roundtrip_flag4: wasmtime::component::ComponentExportIndex,
887                     roundtrip_flag8: wasmtime::component::ComponentExportIndex,
888                     roundtrip_flag16: wasmtime::component::ComponentExportIndex,
889                     roundtrip_flag32: wasmtime::component::ComponentExportIndex,
890                     roundtrip_flag64: wasmtime::component::ComponentExportIndex,
891                 }
892                 impl GuestIndices {
893                     /// Constructor for [`GuestIndices`] which takes a
894                     /// [`Component`](wasmtime::component::Component) as input and can be executed
895                     /// before instantiation.
896                     ///
897                     /// This constructor can be used to front-load string lookups to find exports
898                     /// within a component.
899                     pub fn new<_T>(
900                         _instance_pre: &wasmtime::component::InstancePre<_T>,
901                     ) -> wasmtime::Result<GuestIndices> {
902                         let instance = _instance_pre
903                             .component()
904                             .get_export_index(None, "foo:foo/flegs")
905                             .ok_or_else(|| {
906                                 anyhow::anyhow!(
907                                     "no exported instance named `foo:foo/flegs`"
908                                 )
909                             })?;
910                         let mut lookup = move |name| {
911                             _instance_pre
912                                 .component()
913                                 .get_export_index(Some(&instance), name)
914                                 .ok_or_else(|| {
915                                     anyhow::anyhow!(
916                                         "instance export `foo:foo/flegs` does \
917                 not have export `{name}`"
918                                     )
919                                 })
920                         };
921                         let _ = &mut lookup;
922                         let roundtrip_flag1 = lookup("roundtrip-flag1")?;
923                         let roundtrip_flag2 = lookup("roundtrip-flag2")?;
924                         let roundtrip_flag4 = lookup("roundtrip-flag4")?;
925                         let roundtrip_flag8 = lookup("roundtrip-flag8")?;
926                         let roundtrip_flag16 = lookup("roundtrip-flag16")?;
927                         let roundtrip_flag32 = lookup("roundtrip-flag32")?;
928                         let roundtrip_flag64 = lookup("roundtrip-flag64")?;
929                         Ok(GuestIndices {
930                             roundtrip_flag1,
931                             roundtrip_flag2,
932                             roundtrip_flag4,
933                             roundtrip_flag8,
934                             roundtrip_flag16,
935                             roundtrip_flag32,
936                             roundtrip_flag64,
937                         })
938                     }
939                     pub fn load(
940                         &self,
941                         mut store: impl wasmtime::AsContextMut,
942                         instance: &wasmtime::component::Instance,
943                     ) -> wasmtime::Result<Guest> {
944                         let _instance = instance;
945                         let _instance_pre = _instance.instance_pre(&store);
946                         let _instance_type = _instance_pre.instance_type();
947                         let mut store = store.as_context_mut();
948                         let _ = &mut store;
949                         let roundtrip_flag1 = *_instance
950                             .get_typed_func::<
951                                 (Flag1,),
952                                 (Flag1,),
953                             >(&mut store, &self.roundtrip_flag1)?
954                             .func();
955                         let roundtrip_flag2 = *_instance
956                             .get_typed_func::<
957                                 (Flag2,),
958                                 (Flag2,),
959                             >(&mut store, &self.roundtrip_flag2)?
960                             .func();
961                         let roundtrip_flag4 = *_instance
962                             .get_typed_func::<
963                                 (Flag4,),
964                                 (Flag4,),
965                             >(&mut store, &self.roundtrip_flag4)?
966                             .func();
967                         let roundtrip_flag8 = *_instance
968                             .get_typed_func::<
969                                 (Flag8,),
970                                 (Flag8,),
971                             >(&mut store, &self.roundtrip_flag8)?
972                             .func();
973                         let roundtrip_flag16 = *_instance
974                             .get_typed_func::<
975                                 (Flag16,),
976                                 (Flag16,),
977                             >(&mut store, &self.roundtrip_flag16)?
978                             .func();
979                         let roundtrip_flag32 = *_instance
980                             .get_typed_func::<
981                                 (Flag32,),
982                                 (Flag32,),
983                             >(&mut store, &self.roundtrip_flag32)?
984                             .func();
985                         let roundtrip_flag64 = *_instance
986                             .get_typed_func::<
987                                 (Flag64,),
988                                 (Flag64,),
989                             >(&mut store, &self.roundtrip_flag64)?
990                             .func();
991                         Ok(Guest {
992                             roundtrip_flag1,
993                             roundtrip_flag2,
994                             roundtrip_flag4,
995                             roundtrip_flag8,
996                             roundtrip_flag16,
997                             roundtrip_flag32,
998                             roundtrip_flag64,
999                         })
1000                     }
1001                 }
1002                 impl Guest {
1003                     pub async fn call_roundtrip_flag1<S: wasmtime::AsContextMut>(
1004                         &self,
1005                         mut store: S,
1006                         arg0: Flag1,
1007                     ) -> wasmtime::Result<wasmtime::component::Promise<Flag1>>
1008                     where
1009                         <S as wasmtime::AsContext>::Data: Send + 'static,
1010                     {
1011                         let callee = unsafe {
1012                             wasmtime::component::TypedFunc::<
1013                                 (Flag1,),
1014                                 (Flag1,),
1015                             >::new_unchecked(self.roundtrip_flag1)
1016                         };
1017                         let promise = callee
1018                             .call_concurrent(store.as_context_mut(), (arg0,))
1019                             .await?;
1020                         Ok(promise.map(|(v,)| v))
1021                     }
1022                     pub async fn call_roundtrip_flag2<S: wasmtime::AsContextMut>(
1023                         &self,
1024                         mut store: S,
1025                         arg0: Flag2,
1026                     ) -> wasmtime::Result<wasmtime::component::Promise<Flag2>>
1027                     where
1028                         <S as wasmtime::AsContext>::Data: Send + 'static,
1029                     {
1030                         let callee = unsafe {
1031                             wasmtime::component::TypedFunc::<
1032                                 (Flag2,),
1033                                 (Flag2,),
1034                             >::new_unchecked(self.roundtrip_flag2)
1035                         };
1036                         let promise = callee
1037                             .call_concurrent(store.as_context_mut(), (arg0,))
1038                             .await?;
1039                         Ok(promise.map(|(v,)| v))
1040                     }
1041                     pub async fn call_roundtrip_flag4<S: wasmtime::AsContextMut>(
1042                         &self,
1043                         mut store: S,
1044                         arg0: Flag4,
1045                     ) -> wasmtime::Result<wasmtime::component::Promise<Flag4>>
1046                     where
1047                         <S as wasmtime::AsContext>::Data: Send + 'static,
1048                     {
1049                         let callee = unsafe {
1050                             wasmtime::component::TypedFunc::<
1051                                 (Flag4,),
1052                                 (Flag4,),
1053                             >::new_unchecked(self.roundtrip_flag4)
1054                         };
1055                         let promise = callee
1056                             .call_concurrent(store.as_context_mut(), (arg0,))
1057                             .await?;
1058                         Ok(promise.map(|(v,)| v))
1059                     }
1060                     pub async fn call_roundtrip_flag8<S: wasmtime::AsContextMut>(
1061                         &self,
1062                         mut store: S,
1063                         arg0: Flag8,
1064                     ) -> wasmtime::Result<wasmtime::component::Promise<Flag8>>
1065                     where
1066                         <S as wasmtime::AsContext>::Data: Send + 'static,
1067                     {
1068                         let callee = unsafe {
1069                             wasmtime::component::TypedFunc::<
1070                                 (Flag8,),
1071                                 (Flag8,),
1072                             >::new_unchecked(self.roundtrip_flag8)
1073                         };
1074                         let promise = callee
1075                             .call_concurrent(store.as_context_mut(), (arg0,))
1076                             .await?;
1077                         Ok(promise.map(|(v,)| v))
1078                     }
1079                     pub async fn call_roundtrip_flag16<S: wasmtime::AsContextMut>(
1080                         &self,
1081                         mut store: S,
1082                         arg0: Flag16,
1083                     ) -> wasmtime::Result<wasmtime::component::Promise<Flag16>>
1084                     where
1085                         <S as wasmtime::AsContext>::Data: Send + 'static,
1086                     {
1087                         let callee = unsafe {
1088                             wasmtime::component::TypedFunc::<
1089                                 (Flag16,),
1090                                 (Flag16,),
1091                             >::new_unchecked(self.roundtrip_flag16)
1092                         };
1093                         let promise = callee
1094                             .call_concurrent(store.as_context_mut(), (arg0,))
1095                             .await?;
1096                         Ok(promise.map(|(v,)| v))
1097                     }
1098                     pub async fn call_roundtrip_flag32<S: wasmtime::AsContextMut>(
1099                         &self,
1100                         mut store: S,
1101                         arg0: Flag32,
1102                     ) -> wasmtime::Result<wasmtime::component::Promise<Flag32>>
1103                     where
1104                         <S as wasmtime::AsContext>::Data: Send + 'static,
1105                     {
1106                         let callee = unsafe {
1107                             wasmtime::component::TypedFunc::<
1108                                 (Flag32,),
1109                                 (Flag32,),
1110                             >::new_unchecked(self.roundtrip_flag32)
1111                         };
1112                         let promise = callee
1113                             .call_concurrent(store.as_context_mut(), (arg0,))
1114                             .await?;
1115                         Ok(promise.map(|(v,)| v))
1116                     }
1117                     pub async fn call_roundtrip_flag64<S: wasmtime::AsContextMut>(
1118                         &self,
1119                         mut store: S,
1120                         arg0: Flag64,
1121                     ) -> wasmtime::Result<wasmtime::component::Promise<Flag64>>
1122                     where
1123                         <S as wasmtime::AsContext>::Data: Send + 'static,
1124                     {
1125                         let callee = unsafe {
1126                             wasmtime::component::TypedFunc::<
1127                                 (Flag64,),
1128                                 (Flag64,),
1129                             >::new_unchecked(self.roundtrip_flag64)
1130                         };
1131                         let promise = callee
1132                             .call_concurrent(store.as_context_mut(), (arg0,))
1133                             .await?;
1134                         Ok(promise.map(|(v,)| v))
1135                     }
1136                 }
1137             }
1138         }
1139     }
1140 }
1141