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