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