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