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