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 fn instantiate(
47         &self,
48         mut store: impl wasmtime::AsContextMut<Data = _T>,
49     ) -> wasmtime::Result<TheFlags> {
50         let mut store = store.as_context_mut();
51         let instance = self.instance_pre.instantiate(&mut store)?;
52         self.indices.load(&mut store, &instance)
53     }
54 }
55 impl<_T: Send + 'static> TheFlagsPre<_T> {
56     /// Same as [`Self::instantiate`], except with `async`.
57     pub async fn instantiate_async(
58         &self,
59         mut store: impl wasmtime::AsContextMut<Data = _T>,
60     ) -> wasmtime::Result<TheFlags> {
61         let mut store = store.as_context_mut();
62         let instance = self.instance_pre.instantiate_async(&mut store).await?;
63         self.indices.load(&mut store, &instance)
64     }
65 }
66 /// Auto-generated bindings for index of the exports of
67 /// `the-flags`.
68 ///
69 /// This is an implementation detail of [`TheFlagsPre`] and can
70 /// be constructed if needed as well.
71 ///
72 /// For more information see [`TheFlags`] as well.
73 #[derive(Clone)]
74 pub struct TheFlagsIndices {
75     interface0: exports::foo::foo::flegs::GuestIndices,
76 }
77 /// Auto-generated bindings for an instance a component which
78 /// implements the world `the-flags`.
79 ///
80 /// This structure can be created through a number of means
81 /// depending on your requirements and what you have on hand:
82 ///
83 /// * The most convenient way is to use
84 ///   [`TheFlags::instantiate`] which only needs a
85 ///   [`Store`], [`Component`], and [`Linker`].
86 ///
87 /// * Alternatively you can create a [`TheFlagsPre`] ahead of
88 ///   time with a [`Component`] to front-load string lookups
89 ///   of exports once instead of per-instantiation. This
90 ///   method then uses [`TheFlagsPre::instantiate`] to
91 ///   create a [`TheFlags`].
92 ///
93 /// * If you've instantiated the instance yourself already
94 ///   then you can use [`TheFlags::new`].
95 ///
96 /// These methods are all equivalent to one another and move
97 /// around the tradeoff of what work is performed when.
98 ///
99 /// [`Store`]: wasmtime::Store
100 /// [`Component`]: wasmtime::component::Component
101 /// [`Linker`]: wasmtime::component::Linker
102 pub struct TheFlags {
103     interface0: exports::foo::foo::flegs::Guest,
104 }
105 const _: () = {
106     #[allow(unused_imports)]
107     use wasmtime::component::__internal::anyhow;
108     impl TheFlagsIndices {
109         /// Creates a new copy of `TheFlagsIndices` bindings which can then
110         /// be used to instantiate into a particular store.
111         ///
112         /// This method may fail if the component does not have the
113         /// required exports.
114         pub fn new<_T>(
115             _instance_pre: &wasmtime::component::InstancePre<_T>,
116         ) -> wasmtime::Result<Self> {
117             let _component = _instance_pre.component();
118             let _instance_type = _instance_pre.instance_type();
119             let interface0 = exports::foo::foo::flegs::GuestIndices::new(_instance_pre)?;
120             Ok(TheFlagsIndices { interface0 })
121         }
122         /// Uses the indices stored in `self` to load an instance
123         /// of [`TheFlags`] from the instance provided.
124         ///
125         /// Note that at this time this method will additionally
126         /// perform type-checks of all exports.
127         pub fn load(
128             &self,
129             mut store: impl wasmtime::AsContextMut,
130             instance: &wasmtime::component::Instance,
131         ) -> wasmtime::Result<TheFlags> {
132             let _ = &mut store;
133             let _instance = instance;
134             let interface0 = self.interface0.load(&mut store, &_instance)?;
135             Ok(TheFlags { interface0 })
136         }
137     }
138     impl TheFlags {
139         /// Convenience wrapper around [`TheFlagsPre::new`] and
140         /// [`TheFlagsPre::instantiate`].
141         pub fn instantiate<_T>(
142             store: impl wasmtime::AsContextMut<Data = _T>,
143             component: &wasmtime::component::Component,
144             linker: &wasmtime::component::Linker<_T>,
145         ) -> wasmtime::Result<TheFlags> {
146             let pre = linker.instantiate_pre(component)?;
147             TheFlagsPre::new(pre)?.instantiate(store)
148         }
149         /// Convenience wrapper around [`TheFlagsIndices::new`] and
150         /// [`TheFlagsIndices::load`].
151         pub fn new(
152             mut store: impl wasmtime::AsContextMut,
153             instance: &wasmtime::component::Instance,
154         ) -> wasmtime::Result<TheFlags> {
155             let indices = TheFlagsIndices::new(&instance.instance_pre(&store))?;
156             indices.load(&mut store, instance)
157         }
158         /// Convenience wrapper around [`TheFlagsPre::new`] and
159         /// [`TheFlagsPre::instantiate_async`].
160         pub async fn instantiate_async<_T>(
161             store: impl wasmtime::AsContextMut<Data = _T>,
162             component: &wasmtime::component::Component,
163             linker: &wasmtime::component::Linker<_T>,
164         ) -> wasmtime::Result<TheFlags>
165         where
166             _T: Send,
167         {
168             let pre = linker.instantiate_pre(component)?;
169             TheFlagsPre::new(pre)?.instantiate_async(store).await
170         }
171         pub fn add_to_linker<T, D>(
172             linker: &mut wasmtime::component::Linker<T>,
173             host_getter: fn(&mut T) -> D::Data<'_>,
174         ) -> wasmtime::Result<()>
175         where
176             D: foo::foo::flegs::HostWithStore + Send,
177             for<'a> D::Data<'a>: foo::foo::flegs::Host + Send,
178             T: 'static + Send,
179         {
180             foo::foo::flegs::add_to_linker::<T, D>(linker, host_getter)?;
181             Ok(())
182         }
183         pub fn foo_foo_flegs(&self) -> &exports::foo::foo::flegs::Guest {
184             &self.interface0
185         }
186     }
187 };
188 pub mod foo {
189     pub mod foo {
190         #[allow(clippy::all)]
191         pub mod flegs {
192             #[allow(unused_imports)]
193             use wasmtime::component::__internal::{anyhow, Box};
194             wasmtime::component::flags!(Flag1 { #[component(name = "b0")] const B0; });
195             const _: () = {
196                 assert!(1 == < Flag1 as wasmtime::component::ComponentType >::SIZE32);
197                 assert!(1 == < Flag1 as wasmtime::component::ComponentType >::ALIGN32);
198             };
199             wasmtime::component::flags!(
200                 Flag2 { #[component(name = "b0")] const B0; #[component(name = "b1")]
201                 const B1; }
202             );
203             const _: () = {
204                 assert!(1 == < Flag2 as wasmtime::component::ComponentType >::SIZE32);
205                 assert!(1 == < Flag2 as wasmtime::component::ComponentType >::ALIGN32);
206             };
207             wasmtime::component::flags!(
208                 Flag4 { #[component(name = "b0")] const B0; #[component(name = "b1")]
209                 const B1; #[component(name = "b2")] const B2; #[component(name = "b3")]
210                 const B3; }
211             );
212             const _: () = {
213                 assert!(1 == < Flag4 as wasmtime::component::ComponentType >::SIZE32);
214                 assert!(1 == < Flag4 as wasmtime::component::ComponentType >::ALIGN32);
215             };
216             wasmtime::component::flags!(
217                 Flag8 { #[component(name = "b0")] const B0; #[component(name = "b1")]
218                 const B1; #[component(name = "b2")] const B2; #[component(name = "b3")]
219                 const B3; #[component(name = "b4")] const B4; #[component(name = "b5")]
220                 const B5; #[component(name = "b6")] const B6; #[component(name = "b7")]
221                 const B7; }
222             );
223             const _: () = {
224                 assert!(1 == < Flag8 as wasmtime::component::ComponentType >::SIZE32);
225                 assert!(1 == < Flag8 as wasmtime::component::ComponentType >::ALIGN32);
226             };
227             wasmtime::component::flags!(
228                 Flag16 { #[component(name = "b0")] const B0; #[component(name = "b1")]
229                 const B1; #[component(name = "b2")] const B2; #[component(name = "b3")]
230                 const B3; #[component(name = "b4")] const B4; #[component(name = "b5")]
231                 const B5; #[component(name = "b6")] const B6; #[component(name = "b7")]
232                 const B7; #[component(name = "b8")] const B8; #[component(name = "b9")]
233                 const B9; #[component(name = "b10")] const B10; #[component(name =
234                 "b11")] const B11; #[component(name = "b12")] const B12; #[component(name
235                 = "b13")] const B13; #[component(name = "b14")] const B14;
236                 #[component(name = "b15")] const B15; }
237             );
238             const _: () = {
239                 assert!(2 == < Flag16 as wasmtime::component::ComponentType >::SIZE32);
240                 assert!(2 == < Flag16 as wasmtime::component::ComponentType >::ALIGN32);
241             };
242             wasmtime::component::flags!(
243                 Flag32 { #[component(name = "b0")] const B0; #[component(name = "b1")]
244                 const B1; #[component(name = "b2")] const B2; #[component(name = "b3")]
245                 const B3; #[component(name = "b4")] const B4; #[component(name = "b5")]
246                 const B5; #[component(name = "b6")] const B6; #[component(name = "b7")]
247                 const B7; #[component(name = "b8")] const B8; #[component(name = "b9")]
248                 const B9; #[component(name = "b10")] const B10; #[component(name =
249                 "b11")] const B11; #[component(name = "b12")] const B12; #[component(name
250                 = "b13")] const B13; #[component(name = "b14")] const B14;
251                 #[component(name = "b15")] const B15; #[component(name = "b16")] const
252                 B16; #[component(name = "b17")] const B17; #[component(name = "b18")]
253                 const B18; #[component(name = "b19")] const B19; #[component(name =
254                 "b20")] const B20; #[component(name = "b21")] const B21; #[component(name
255                 = "b22")] const B22; #[component(name = "b23")] const B23;
256                 #[component(name = "b24")] const B24; #[component(name = "b25")] const
257                 B25; #[component(name = "b26")] const B26; #[component(name = "b27")]
258                 const B27; #[component(name = "b28")] const B28; #[component(name =
259                 "b29")] const B29; #[component(name = "b30")] const B30; #[component(name
260                 = "b31")] const B31; }
261             );
262             const _: () = {
263                 assert!(4 == < Flag32 as wasmtime::component::ComponentType >::SIZE32);
264                 assert!(4 == < Flag32 as wasmtime::component::ComponentType >::ALIGN32);
265             };
266             wasmtime::component::flags!(
267                 Flag64 { #[component(name = "b0")] const B0; #[component(name = "b1")]
268                 const B1; #[component(name = "b2")] const B2; #[component(name = "b3")]
269                 const B3; #[component(name = "b4")] const B4; #[component(name = "b5")]
270                 const B5; #[component(name = "b6")] const B6; #[component(name = "b7")]
271                 const B7; #[component(name = "b8")] const B8; #[component(name = "b9")]
272                 const B9; #[component(name = "b10")] const B10; #[component(name =
273                 "b11")] const B11; #[component(name = "b12")] const B12; #[component(name
274                 = "b13")] const B13; #[component(name = "b14")] const B14;
275                 #[component(name = "b15")] const B15; #[component(name = "b16")] const
276                 B16; #[component(name = "b17")] const B17; #[component(name = "b18")]
277                 const B18; #[component(name = "b19")] const B19; #[component(name =
278                 "b20")] const B20; #[component(name = "b21")] const B21; #[component(name
279                 = "b22")] const B22; #[component(name = "b23")] const B23;
280                 #[component(name = "b24")] const B24; #[component(name = "b25")] const
281                 B25; #[component(name = "b26")] const B26; #[component(name = "b27")]
282                 const B27; #[component(name = "b28")] const B28; #[component(name =
283                 "b29")] const B29; #[component(name = "b30")] const B30; #[component(name
284                 = "b31")] const B31; #[component(name = "b32")] const B32;
285                 #[component(name = "b33")] const B33; #[component(name = "b34")] const
286                 B34; #[component(name = "b35")] const B35; #[component(name = "b36")]
287                 const B36; #[component(name = "b37")] const B37; #[component(name =
288                 "b38")] const B38; #[component(name = "b39")] const B39; #[component(name
289                 = "b40")] const B40; #[component(name = "b41")] const B41;
290                 #[component(name = "b42")] const B42; #[component(name = "b43")] const
291                 B43; #[component(name = "b44")] const B44; #[component(name = "b45")]
292                 const B45; #[component(name = "b46")] const B46; #[component(name =
293                 "b47")] const B47; #[component(name = "b48")] const B48; #[component(name
294                 = "b49")] const B49; #[component(name = "b50")] const B50;
295                 #[component(name = "b51")] const B51; #[component(name = "b52")] const
296                 B52; #[component(name = "b53")] const B53; #[component(name = "b54")]
297                 const B54; #[component(name = "b55")] const B55; #[component(name =
298                 "b56")] const B56; #[component(name = "b57")] const B57; #[component(name
299                 = "b58")] const B58; #[component(name = "b59")] const B59;
300                 #[component(name = "b60")] const B60; #[component(name = "b61")] const
301                 B61; #[component(name = "b62")] const B62; #[component(name = "b63")]
302                 const B63; }
303             );
304             const _: () = {
305                 assert!(8 == < Flag64 as wasmtime::component::ComponentType >::SIZE32);
306                 assert!(4 == < Flag64 as wasmtime::component::ComponentType >::ALIGN32);
307             };
308             pub trait HostWithStore: wasmtime::component::HasData + Send {}
309             impl<_T: ?Sized> HostWithStore for _T
310             where
311                 _T: wasmtime::component::HasData + Send,
312             {}
313             pub trait Host: Send {
314                 fn roundtrip_flag1(
315                     &mut self,
316                     x: Flag1,
317                 ) -> impl ::core::future::Future<Output = Flag1> + Send;
318                 fn roundtrip_flag2(
319                     &mut self,
320                     x: Flag2,
321                 ) -> impl ::core::future::Future<Output = Flag2> + Send;
322                 fn roundtrip_flag4(
323                     &mut self,
324                     x: Flag4,
325                 ) -> impl ::core::future::Future<Output = Flag4> + Send;
326                 fn roundtrip_flag8(
327                     &mut self,
328                     x: Flag8,
329                 ) -> impl ::core::future::Future<Output = Flag8> + Send;
330                 fn roundtrip_flag16(
331                     &mut self,
332                     x: Flag16,
333                 ) -> impl ::core::future::Future<Output = Flag16> + Send;
334                 fn roundtrip_flag32(
335                     &mut self,
336                     x: Flag32,
337                 ) -> impl ::core::future::Future<Output = Flag32> + Send;
338                 fn roundtrip_flag64(
339                     &mut self,
340                     x: Flag64,
341                 ) -> impl ::core::future::Future<Output = Flag64> + Send;
342             }
343             impl<_T: Host + ?Sized + Send> Host for &mut _T {
344                 fn roundtrip_flag1(
345                     &mut self,
346                     x: Flag1,
347                 ) -> impl ::core::future::Future<Output = Flag1> + Send {
348                     async move { Host::roundtrip_flag1(*self, x).await }
349                 }
350                 fn roundtrip_flag2(
351                     &mut self,
352                     x: Flag2,
353                 ) -> impl ::core::future::Future<Output = Flag2> + Send {
354                     async move { Host::roundtrip_flag2(*self, x).await }
355                 }
356                 fn roundtrip_flag4(
357                     &mut self,
358                     x: Flag4,
359                 ) -> impl ::core::future::Future<Output = Flag4> + Send {
360                     async move { Host::roundtrip_flag4(*self, x).await }
361                 }
362                 fn roundtrip_flag8(
363                     &mut self,
364                     x: Flag8,
365                 ) -> impl ::core::future::Future<Output = Flag8> + Send {
366                     async move { Host::roundtrip_flag8(*self, x).await }
367                 }
368                 fn roundtrip_flag16(
369                     &mut self,
370                     x: Flag16,
371                 ) -> impl ::core::future::Future<Output = Flag16> + Send {
372                     async move { Host::roundtrip_flag16(*self, x).await }
373                 }
374                 fn roundtrip_flag32(
375                     &mut self,
376                     x: Flag32,
377                 ) -> impl ::core::future::Future<Output = Flag32> + Send {
378                     async move { Host::roundtrip_flag32(*self, x).await }
379                 }
380                 fn roundtrip_flag64(
381                     &mut self,
382                     x: Flag64,
383                 ) -> impl ::core::future::Future<Output = Flag64> + Send {
384                     async move { Host::roundtrip_flag64(*self, x).await }
385                 }
386             }
387             pub fn add_to_linker<T, D>(
388                 linker: &mut wasmtime::component::Linker<T>,
389                 host_getter: fn(&mut T) -> D::Data<'_>,
390             ) -> wasmtime::Result<()>
391             where
392                 D: HostWithStore,
393                 for<'a> D::Data<'a>: Host,
394                 T: 'static + Send,
395             {
396                 let mut inst = linker.instance("foo:foo/flegs")?;
397                 inst.func_wrap_async(
398                     "roundtrip-flag1",
399                     move |
400                         mut caller: wasmtime::StoreContextMut<'_, T>,
401                         (arg0,): (Flag1,)|
402                     {
403                         wasmtime::component::__internal::Box::new(async move {
404                             let host = &mut host_getter(caller.data_mut());
405                             let r = Host::roundtrip_flag1(host, arg0).await;
406                             Ok((r,))
407                         })
408                     },
409                 )?;
410                 inst.func_wrap_async(
411                     "roundtrip-flag2",
412                     move |
413                         mut caller: wasmtime::StoreContextMut<'_, T>,
414                         (arg0,): (Flag2,)|
415                     {
416                         wasmtime::component::__internal::Box::new(async move {
417                             let host = &mut host_getter(caller.data_mut());
418                             let r = Host::roundtrip_flag2(host, arg0).await;
419                             Ok((r,))
420                         })
421                     },
422                 )?;
423                 inst.func_wrap_async(
424                     "roundtrip-flag4",
425                     move |
426                         mut caller: wasmtime::StoreContextMut<'_, T>,
427                         (arg0,): (Flag4,)|
428                     {
429                         wasmtime::component::__internal::Box::new(async move {
430                             let host = &mut host_getter(caller.data_mut());
431                             let r = Host::roundtrip_flag4(host, arg0).await;
432                             Ok((r,))
433                         })
434                     },
435                 )?;
436                 inst.func_wrap_async(
437                     "roundtrip-flag8",
438                     move |
439                         mut caller: wasmtime::StoreContextMut<'_, T>,
440                         (arg0,): (Flag8,)|
441                     {
442                         wasmtime::component::__internal::Box::new(async move {
443                             let host = &mut host_getter(caller.data_mut());
444                             let r = Host::roundtrip_flag8(host, arg0).await;
445                             Ok((r,))
446                         })
447                     },
448                 )?;
449                 inst.func_wrap_async(
450                     "roundtrip-flag16",
451                     move |
452                         mut caller: wasmtime::StoreContextMut<'_, T>,
453                         (arg0,): (Flag16,)|
454                     {
455                         wasmtime::component::__internal::Box::new(async move {
456                             let host = &mut host_getter(caller.data_mut());
457                             let r = Host::roundtrip_flag16(host, arg0).await;
458                             Ok((r,))
459                         })
460                     },
461                 )?;
462                 inst.func_wrap_async(
463                     "roundtrip-flag32",
464                     move |
465                         mut caller: wasmtime::StoreContextMut<'_, T>,
466                         (arg0,): (Flag32,)|
467                     {
468                         wasmtime::component::__internal::Box::new(async move {
469                             let host = &mut host_getter(caller.data_mut());
470                             let r = Host::roundtrip_flag32(host, arg0).await;
471                             Ok((r,))
472                         })
473                     },
474                 )?;
475                 inst.func_wrap_async(
476                     "roundtrip-flag64",
477                     move |
478                         mut caller: wasmtime::StoreContextMut<'_, T>,
479                         (arg0,): (Flag64,)|
480                     {
481                         wasmtime::component::__internal::Box::new(async move {
482                             let host = &mut host_getter(caller.data_mut());
483                             let r = Host::roundtrip_flag64(host, arg0).await;
484                             Ok((r,))
485                         })
486                     },
487                 )?;
488                 Ok(())
489             }
490         }
491     }
492 }
493 pub mod exports {
494     pub mod foo {
495         pub mod foo {
496             #[allow(clippy::all)]
497             pub mod flegs {
498                 #[allow(unused_imports)]
499                 use wasmtime::component::__internal::{anyhow, Box};
500                 wasmtime::component::flags!(
501                     Flag1 { #[component(name = "b0")] const B0; }
502                 );
503                 const _: () = {
504                     assert!(
505                         1 == < Flag1 as wasmtime::component::ComponentType >::SIZE32
506                     );
507                     assert!(
508                         1 == < Flag1 as wasmtime::component::ComponentType >::ALIGN32
509                     );
510                 };
511                 wasmtime::component::flags!(
512                     Flag2 { #[component(name = "b0")] const B0; #[component(name = "b1")]
513                     const B1; }
514                 );
515                 const _: () = {
516                     assert!(
517                         1 == < Flag2 as wasmtime::component::ComponentType >::SIZE32
518                     );
519                     assert!(
520                         1 == < Flag2 as wasmtime::component::ComponentType >::ALIGN32
521                     );
522                 };
523                 wasmtime::component::flags!(
524                     Flag4 { #[component(name = "b0")] const B0; #[component(name = "b1")]
525                     const B1; #[component(name = "b2")] const B2; #[component(name =
526                     "b3")] const B3; }
527                 );
528                 const _: () = {
529                     assert!(
530                         1 == < Flag4 as wasmtime::component::ComponentType >::SIZE32
531                     );
532                     assert!(
533                         1 == < Flag4 as wasmtime::component::ComponentType >::ALIGN32
534                     );
535                 };
536                 wasmtime::component::flags!(
537                     Flag8 { #[component(name = "b0")] const B0; #[component(name = "b1")]
538                     const B1; #[component(name = "b2")] const B2; #[component(name =
539                     "b3")] const B3; #[component(name = "b4")] const B4; #[component(name
540                     = "b5")] const B5; #[component(name = "b6")] const B6;
541                     #[component(name = "b7")] const B7; }
542                 );
543                 const _: () = {
544                     assert!(
545                         1 == < Flag8 as wasmtime::component::ComponentType >::SIZE32
546                     );
547                     assert!(
548                         1 == < Flag8 as wasmtime::component::ComponentType >::ALIGN32
549                     );
550                 };
551                 wasmtime::component::flags!(
552                     Flag16 { #[component(name = "b0")] const B0; #[component(name =
553                     "b1")] const B1; #[component(name = "b2")] const B2; #[component(name
554                     = "b3")] const B3; #[component(name = "b4")] const B4;
555                     #[component(name = "b5")] const B5; #[component(name = "b6")] const
556                     B6; #[component(name = "b7")] const B7; #[component(name = "b8")]
557                     const B8; #[component(name = "b9")] const B9; #[component(name =
558                     "b10")] const B10; #[component(name = "b11")] const B11;
559                     #[component(name = "b12")] const B12; #[component(name = "b13")]
560                     const B13; #[component(name = "b14")] const B14; #[component(name =
561                     "b15")] const B15; }
562                 );
563                 const _: () = {
564                     assert!(
565                         2 == < Flag16 as wasmtime::component::ComponentType >::SIZE32
566                     );
567                     assert!(
568                         2 == < Flag16 as wasmtime::component::ComponentType >::ALIGN32
569                     );
570                 };
571                 wasmtime::component::flags!(
572                     Flag32 { #[component(name = "b0")] const B0; #[component(name =
573                     "b1")] const B1; #[component(name = "b2")] const B2; #[component(name
574                     = "b3")] const B3; #[component(name = "b4")] const B4;
575                     #[component(name = "b5")] const B5; #[component(name = "b6")] const
576                     B6; #[component(name = "b7")] const B7; #[component(name = "b8")]
577                     const B8; #[component(name = "b9")] const B9; #[component(name =
578                     "b10")] const B10; #[component(name = "b11")] const B11;
579                     #[component(name = "b12")] const B12; #[component(name = "b13")]
580                     const B13; #[component(name = "b14")] const B14; #[component(name =
581                     "b15")] const B15; #[component(name = "b16")] const B16;
582                     #[component(name = "b17")] const B17; #[component(name = "b18")]
583                     const B18; #[component(name = "b19")] const B19; #[component(name =
584                     "b20")] const B20; #[component(name = "b21")] const B21;
585                     #[component(name = "b22")] const B22; #[component(name = "b23")]
586                     const B23; #[component(name = "b24")] const B24; #[component(name =
587                     "b25")] const B25; #[component(name = "b26")] const B26;
588                     #[component(name = "b27")] const B27; #[component(name = "b28")]
589                     const B28; #[component(name = "b29")] const B29; #[component(name =
590                     "b30")] const B30; #[component(name = "b31")] const B31; }
591                 );
592                 const _: () = {
593                     assert!(
594                         4 == < Flag32 as wasmtime::component::ComponentType >::SIZE32
595                     );
596                     assert!(
597                         4 == < Flag32 as wasmtime::component::ComponentType >::ALIGN32
598                     );
599                 };
600                 wasmtime::component::flags!(
601                     Flag64 { #[component(name = "b0")] const B0; #[component(name =
602                     "b1")] const B1; #[component(name = "b2")] const B2; #[component(name
603                     = "b3")] const B3; #[component(name = "b4")] const B4;
604                     #[component(name = "b5")] const B5; #[component(name = "b6")] const
605                     B6; #[component(name = "b7")] const B7; #[component(name = "b8")]
606                     const B8; #[component(name = "b9")] const B9; #[component(name =
607                     "b10")] const B10; #[component(name = "b11")] const B11;
608                     #[component(name = "b12")] const B12; #[component(name = "b13")]
609                     const B13; #[component(name = "b14")] const B14; #[component(name =
610                     "b15")] const B15; #[component(name = "b16")] const B16;
611                     #[component(name = "b17")] const B17; #[component(name = "b18")]
612                     const B18; #[component(name = "b19")] const B19; #[component(name =
613                     "b20")] const B20; #[component(name = "b21")] const B21;
614                     #[component(name = "b22")] const B22; #[component(name = "b23")]
615                     const B23; #[component(name = "b24")] const B24; #[component(name =
616                     "b25")] const B25; #[component(name = "b26")] const B26;
617                     #[component(name = "b27")] const B27; #[component(name = "b28")]
618                     const B28; #[component(name = "b29")] const B29; #[component(name =
619                     "b30")] const B30; #[component(name = "b31")] const B31;
620                     #[component(name = "b32")] const B32; #[component(name = "b33")]
621                     const B33; #[component(name = "b34")] const B34; #[component(name =
622                     "b35")] const B35; #[component(name = "b36")] const B36;
623                     #[component(name = "b37")] const B37; #[component(name = "b38")]
624                     const B38; #[component(name = "b39")] const B39; #[component(name =
625                     "b40")] const B40; #[component(name = "b41")] const B41;
626                     #[component(name = "b42")] const B42; #[component(name = "b43")]
627                     const B43; #[component(name = "b44")] const B44; #[component(name =
628                     "b45")] const B45; #[component(name = "b46")] const B46;
629                     #[component(name = "b47")] const B47; #[component(name = "b48")]
630                     const B48; #[component(name = "b49")] const B49; #[component(name =
631                     "b50")] const B50; #[component(name = "b51")] const B51;
632                     #[component(name = "b52")] const B52; #[component(name = "b53")]
633                     const B53; #[component(name = "b54")] const B54; #[component(name =
634                     "b55")] const B55; #[component(name = "b56")] const B56;
635                     #[component(name = "b57")] const B57; #[component(name = "b58")]
636                     const B58; #[component(name = "b59")] const B59; #[component(name =
637                     "b60")] const B60; #[component(name = "b61")] const B61;
638                     #[component(name = "b62")] const B62; #[component(name = "b63")]
639                     const B63; }
640                 );
641                 const _: () = {
642                     assert!(
643                         8 == < Flag64 as wasmtime::component::ComponentType >::SIZE32
644                     );
645                     assert!(
646                         4 == < Flag64 as wasmtime::component::ComponentType >::ALIGN32
647                     );
648                 };
649                 #[derive(Clone)]
650                 pub struct Guest {
651                     roundtrip_flag1: wasmtime::component::Func,
652                     roundtrip_flag2: wasmtime::component::Func,
653                     roundtrip_flag4: wasmtime::component::Func,
654                     roundtrip_flag8: wasmtime::component::Func,
655                     roundtrip_flag16: wasmtime::component::Func,
656                     roundtrip_flag32: wasmtime::component::Func,
657                     roundtrip_flag64: wasmtime::component::Func,
658                 }
659                 #[derive(Clone)]
660                 pub struct GuestIndices {
661                     roundtrip_flag1: wasmtime::component::ComponentExportIndex,
662                     roundtrip_flag2: wasmtime::component::ComponentExportIndex,
663                     roundtrip_flag4: wasmtime::component::ComponentExportIndex,
664                     roundtrip_flag8: wasmtime::component::ComponentExportIndex,
665                     roundtrip_flag16: wasmtime::component::ComponentExportIndex,
666                     roundtrip_flag32: wasmtime::component::ComponentExportIndex,
667                     roundtrip_flag64: wasmtime::component::ComponentExportIndex,
668                 }
669                 impl GuestIndices {
670                     /// Constructor for [`GuestIndices`] which takes a
671                     /// [`Component`](wasmtime::component::Component) as input and can be executed
672                     /// before instantiation.
673                     ///
674                     /// This constructor can be used to front-load string lookups to find exports
675                     /// within a component.
676                     pub fn new<_T>(
677                         _instance_pre: &wasmtime::component::InstancePre<_T>,
678                     ) -> wasmtime::Result<GuestIndices> {
679                         let instance = _instance_pre
680                             .component()
681                             .get_export_index(None, "foo:foo/flegs")
682                             .ok_or_else(|| {
683                                 anyhow::anyhow!(
684                                     "no exported instance named `foo:foo/flegs`"
685                                 )
686                             })?;
687                         let mut lookup = move |name| {
688                             _instance_pre
689                                 .component()
690                                 .get_export_index(Some(&instance), name)
691                                 .ok_or_else(|| {
692                                     anyhow::anyhow!(
693                                         "instance export `foo:foo/flegs` does \
694                               not have export `{name}`"
695                                     )
696                                 })
697                         };
698                         let _ = &mut lookup;
699                         let roundtrip_flag1 = lookup("roundtrip-flag1")?;
700                         let roundtrip_flag2 = lookup("roundtrip-flag2")?;
701                         let roundtrip_flag4 = lookup("roundtrip-flag4")?;
702                         let roundtrip_flag8 = lookup("roundtrip-flag8")?;
703                         let roundtrip_flag16 = lookup("roundtrip-flag16")?;
704                         let roundtrip_flag32 = lookup("roundtrip-flag32")?;
705                         let roundtrip_flag64 = lookup("roundtrip-flag64")?;
706                         Ok(GuestIndices {
707                             roundtrip_flag1,
708                             roundtrip_flag2,
709                             roundtrip_flag4,
710                             roundtrip_flag8,
711                             roundtrip_flag16,
712                             roundtrip_flag32,
713                             roundtrip_flag64,
714                         })
715                     }
716                     pub fn load(
717                         &self,
718                         mut store: impl wasmtime::AsContextMut,
719                         instance: &wasmtime::component::Instance,
720                     ) -> wasmtime::Result<Guest> {
721                         let _instance = instance;
722                         let _instance_pre = _instance.instance_pre(&store);
723                         let _instance_type = _instance_pre.instance_type();
724                         let mut store = store.as_context_mut();
725                         let _ = &mut store;
726                         let roundtrip_flag1 = *_instance
727                             .get_typed_func::<
728                                 (Flag1,),
729                                 (Flag1,),
730                             >(&mut store, &self.roundtrip_flag1)?
731                             .func();
732                         let roundtrip_flag2 = *_instance
733                             .get_typed_func::<
734                                 (Flag2,),
735                                 (Flag2,),
736                             >(&mut store, &self.roundtrip_flag2)?
737                             .func();
738                         let roundtrip_flag4 = *_instance
739                             .get_typed_func::<
740                                 (Flag4,),
741                                 (Flag4,),
742                             >(&mut store, &self.roundtrip_flag4)?
743                             .func();
744                         let roundtrip_flag8 = *_instance
745                             .get_typed_func::<
746                                 (Flag8,),
747                                 (Flag8,),
748                             >(&mut store, &self.roundtrip_flag8)?
749                             .func();
750                         let roundtrip_flag16 = *_instance
751                             .get_typed_func::<
752                                 (Flag16,),
753                                 (Flag16,),
754                             >(&mut store, &self.roundtrip_flag16)?
755                             .func();
756                         let roundtrip_flag32 = *_instance
757                             .get_typed_func::<
758                                 (Flag32,),
759                                 (Flag32,),
760                             >(&mut store, &self.roundtrip_flag32)?
761                             .func();
762                         let roundtrip_flag64 = *_instance
763                             .get_typed_func::<
764                                 (Flag64,),
765                                 (Flag64,),
766                             >(&mut store, &self.roundtrip_flag64)?
767                             .func();
768                         Ok(Guest {
769                             roundtrip_flag1,
770                             roundtrip_flag2,
771                             roundtrip_flag4,
772                             roundtrip_flag8,
773                             roundtrip_flag16,
774                             roundtrip_flag32,
775                             roundtrip_flag64,
776                         })
777                     }
778                 }
779                 impl Guest {
780                     pub async fn call_roundtrip_flag1<S: wasmtime::AsContextMut>(
781                         &self,
782                         mut store: S,
783                         arg0: Flag1,
784                     ) -> wasmtime::Result<Flag1>
785                     where
786                         <S as wasmtime::AsContext>::Data: Send,
787                     {
788                         let callee = unsafe {
789                             wasmtime::component::TypedFunc::<
790                                 (Flag1,),
791                                 (Flag1,),
792                             >::new_unchecked(self.roundtrip_flag1)
793                         };
794                         let (ret0,) = callee
795                             .call_async(store.as_context_mut(), (arg0,))
796                             .await?;
797                         callee.post_return_async(store.as_context_mut()).await?;
798                         Ok(ret0)
799                     }
800                     pub async fn call_roundtrip_flag2<S: wasmtime::AsContextMut>(
801                         &self,
802                         mut store: S,
803                         arg0: Flag2,
804                     ) -> wasmtime::Result<Flag2>
805                     where
806                         <S as wasmtime::AsContext>::Data: Send,
807                     {
808                         let callee = unsafe {
809                             wasmtime::component::TypedFunc::<
810                                 (Flag2,),
811                                 (Flag2,),
812                             >::new_unchecked(self.roundtrip_flag2)
813                         };
814                         let (ret0,) = callee
815                             .call_async(store.as_context_mut(), (arg0,))
816                             .await?;
817                         callee.post_return_async(store.as_context_mut()).await?;
818                         Ok(ret0)
819                     }
820                     pub async fn call_roundtrip_flag4<S: wasmtime::AsContextMut>(
821                         &self,
822                         mut store: S,
823                         arg0: Flag4,
824                     ) -> wasmtime::Result<Flag4>
825                     where
826                         <S as wasmtime::AsContext>::Data: Send,
827                     {
828                         let callee = unsafe {
829                             wasmtime::component::TypedFunc::<
830                                 (Flag4,),
831                                 (Flag4,),
832                             >::new_unchecked(self.roundtrip_flag4)
833                         };
834                         let (ret0,) = callee
835                             .call_async(store.as_context_mut(), (arg0,))
836                             .await?;
837                         callee.post_return_async(store.as_context_mut()).await?;
838                         Ok(ret0)
839                     }
840                     pub async fn call_roundtrip_flag8<S: wasmtime::AsContextMut>(
841                         &self,
842                         mut store: S,
843                         arg0: Flag8,
844                     ) -> wasmtime::Result<Flag8>
845                     where
846                         <S as wasmtime::AsContext>::Data: Send,
847                     {
848                         let callee = unsafe {
849                             wasmtime::component::TypedFunc::<
850                                 (Flag8,),
851                                 (Flag8,),
852                             >::new_unchecked(self.roundtrip_flag8)
853                         };
854                         let (ret0,) = callee
855                             .call_async(store.as_context_mut(), (arg0,))
856                             .await?;
857                         callee.post_return_async(store.as_context_mut()).await?;
858                         Ok(ret0)
859                     }
860                     pub async fn call_roundtrip_flag16<S: wasmtime::AsContextMut>(
861                         &self,
862                         mut store: S,
863                         arg0: Flag16,
864                     ) -> wasmtime::Result<Flag16>
865                     where
866                         <S as wasmtime::AsContext>::Data: Send,
867                     {
868                         let callee = unsafe {
869                             wasmtime::component::TypedFunc::<
870                                 (Flag16,),
871                                 (Flag16,),
872                             >::new_unchecked(self.roundtrip_flag16)
873                         };
874                         let (ret0,) = callee
875                             .call_async(store.as_context_mut(), (arg0,))
876                             .await?;
877                         callee.post_return_async(store.as_context_mut()).await?;
878                         Ok(ret0)
879                     }
880                     pub async fn call_roundtrip_flag32<S: wasmtime::AsContextMut>(
881                         &self,
882                         mut store: S,
883                         arg0: Flag32,
884                     ) -> wasmtime::Result<Flag32>
885                     where
886                         <S as wasmtime::AsContext>::Data: Send,
887                     {
888                         let callee = unsafe {
889                             wasmtime::component::TypedFunc::<
890                                 (Flag32,),
891                                 (Flag32,),
892                             >::new_unchecked(self.roundtrip_flag32)
893                         };
894                         let (ret0,) = callee
895                             .call_async(store.as_context_mut(), (arg0,))
896                             .await?;
897                         callee.post_return_async(store.as_context_mut()).await?;
898                         Ok(ret0)
899                     }
900                     pub async fn call_roundtrip_flag64<S: wasmtime::AsContextMut>(
901                         &self,
902                         mut store: S,
903                         arg0: Flag64,
904                     ) -> wasmtime::Result<Flag64>
905                     where
906                         <S as wasmtime::AsContext>::Data: Send,
907                     {
908                         let callee = unsafe {
909                             wasmtime::component::TypedFunc::<
910                                 (Flag64,),
911                                 (Flag64,),
912                             >::new_unchecked(self.roundtrip_flag64)
913                         };
914                         let (ret0,) = callee
915                             .call_async(store.as_context_mut(), (arg0,))
916                             .await?;
917                         callee.post_return_async(store.as_context_mut()).await?;
918                         Ok(ret0)
919                     }
920                 }
921             }
922         }
923     }
924 }
925