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, for<'a> D::Data<'a>: foo::foo::flegs::Host, T: 'static,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,
175             for<'a> D::Data<'a>: foo::foo::flegs::Host,
176             T: 'static,
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 {}
307             impl<_T: ?Sized> HostWithStore for _T
308             where
309                 _T: wasmtime::component::HasData,
310             {}
311             pub trait Host {
roundtrip_flag1(&mut self, x: Flag1) -> Flag1312                 fn roundtrip_flag1(&mut self, x: Flag1) -> Flag1;
roundtrip_flag2(&mut self, x: Flag2) -> Flag2313                 fn roundtrip_flag2(&mut self, x: Flag2) -> Flag2;
roundtrip_flag4(&mut self, x: Flag4) -> Flag4314                 fn roundtrip_flag4(&mut self, x: Flag4) -> Flag4;
roundtrip_flag8(&mut self, x: Flag8) -> Flag8315                 fn roundtrip_flag8(&mut self, x: Flag8) -> Flag8;
roundtrip_flag16(&mut self, x: Flag16) -> Flag16316                 fn roundtrip_flag16(&mut self, x: Flag16) -> Flag16;
roundtrip_flag32(&mut self, x: Flag32) -> Flag32317                 fn roundtrip_flag32(&mut self, x: Flag32) -> Flag32;
roundtrip_flag64(&mut self, x: Flag64) -> Flag64318                 fn roundtrip_flag64(&mut self, x: Flag64) -> Flag64;
319             }
320             impl<_T: Host + ?Sized> Host for &mut _T {
roundtrip_flag1(&mut self, x: Flag1) -> Flag1321                 fn roundtrip_flag1(&mut self, x: Flag1) -> Flag1 {
322                     Host::roundtrip_flag1(*self, x)
323                 }
roundtrip_flag2(&mut self, x: Flag2) -> Flag2324                 fn roundtrip_flag2(&mut self, x: Flag2) -> Flag2 {
325                     Host::roundtrip_flag2(*self, x)
326                 }
roundtrip_flag4(&mut self, x: Flag4) -> Flag4327                 fn roundtrip_flag4(&mut self, x: Flag4) -> Flag4 {
328                     Host::roundtrip_flag4(*self, x)
329                 }
roundtrip_flag8(&mut self, x: Flag8) -> Flag8330                 fn roundtrip_flag8(&mut self, x: Flag8) -> Flag8 {
331                     Host::roundtrip_flag8(*self, x)
332                 }
roundtrip_flag16(&mut self, x: Flag16) -> Flag16333                 fn roundtrip_flag16(&mut self, x: Flag16) -> Flag16 {
334                     Host::roundtrip_flag16(*self, x)
335                 }
roundtrip_flag32(&mut self, x: Flag32) -> Flag32336                 fn roundtrip_flag32(&mut self, x: Flag32) -> Flag32 {
337                     Host::roundtrip_flag32(*self, x)
338                 }
roundtrip_flag64(&mut self, x: Flag64) -> Flag64339                 fn roundtrip_flag64(&mut self, x: Flag64) -> Flag64 {
340                     Host::roundtrip_flag64(*self, x)
341                 }
342             }
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,343             pub fn add_to_linker<T, D>(
344                 linker: &mut wasmtime::component::Linker<T>,
345                 host_getter: fn(&mut T) -> D::Data<'_>,
346             ) -> wasmtime::Result<()>
347             where
348                 D: HostWithStore,
349                 for<'a> D::Data<'a>: Host,
350                 T: 'static,
351             {
352                 let mut inst = linker.instance("foo:foo/flegs")?;
353                 inst.func_wrap(
354                     "roundtrip-flag1",
355                     move |
356                         mut caller: wasmtime::StoreContextMut<'_, T>,
357                         (arg0,): (Flag1,)|
358                     {
359                         let host = &mut host_getter(caller.data_mut());
360                         let r = Host::roundtrip_flag1(host, arg0);
361                         Ok((r,))
362                     },
363                 )?;
364                 inst.func_wrap(
365                     "roundtrip-flag2",
366                     move |
367                         mut caller: wasmtime::StoreContextMut<'_, T>,
368                         (arg0,): (Flag2,)|
369                     {
370                         let host = &mut host_getter(caller.data_mut());
371                         let r = Host::roundtrip_flag2(host, arg0);
372                         Ok((r,))
373                     },
374                 )?;
375                 inst.func_wrap(
376                     "roundtrip-flag4",
377                     move |
378                         mut caller: wasmtime::StoreContextMut<'_, T>,
379                         (arg0,): (Flag4,)|
380                     {
381                         let host = &mut host_getter(caller.data_mut());
382                         let r = Host::roundtrip_flag4(host, arg0);
383                         Ok((r,))
384                     },
385                 )?;
386                 inst.func_wrap(
387                     "roundtrip-flag8",
388                     move |
389                         mut caller: wasmtime::StoreContextMut<'_, T>,
390                         (arg0,): (Flag8,)|
391                     {
392                         let host = &mut host_getter(caller.data_mut());
393                         let r = Host::roundtrip_flag8(host, arg0);
394                         Ok((r,))
395                     },
396                 )?;
397                 inst.func_wrap(
398                     "roundtrip-flag16",
399                     move |
400                         mut caller: wasmtime::StoreContextMut<'_, T>,
401                         (arg0,): (Flag16,)|
402                     {
403                         let host = &mut host_getter(caller.data_mut());
404                         let r = Host::roundtrip_flag16(host, arg0);
405                         Ok((r,))
406                     },
407                 )?;
408                 inst.func_wrap(
409                     "roundtrip-flag32",
410                     move |
411                         mut caller: wasmtime::StoreContextMut<'_, T>,
412                         (arg0,): (Flag32,)|
413                     {
414                         let host = &mut host_getter(caller.data_mut());
415                         let r = Host::roundtrip_flag32(host, arg0);
416                         Ok((r,))
417                     },
418                 )?;
419                 inst.func_wrap(
420                     "roundtrip-flag64",
421                     move |
422                         mut caller: wasmtime::StoreContextMut<'_, T>,
423                         (arg0,): (Flag64,)|
424                     {
425                         let host = &mut host_getter(caller.data_mut());
426                         let r = Host::roundtrip_flag64(host, arg0);
427                         Ok((r,))
428                     },
429                 )?;
430                 Ok(())
431             }
432         }
433     }
434 }
435 pub mod exports {
436     pub mod foo {
437         pub mod foo {
438             #[allow(clippy::all)]
439             pub mod flegs {
440                 #[allow(unused_imports)]
441                 use wasmtime::component::__internal::Box;
442                 wasmtime::component::flags!(
443                     Flag1 { #[component(name = "b0")] const B0; }
444                 );
445                 const _: () = {
446                     assert!(
447                         1 == < Flag1 as wasmtime::component::ComponentType >::SIZE32
448                     );
449                     assert!(
450                         1 == < Flag1 as wasmtime::component::ComponentType >::ALIGN32
451                     );
452                 };
453                 wasmtime::component::flags!(
454                     Flag2 { #[component(name = "b0")] const B0; #[component(name = "b1")]
455                     const B1; }
456                 );
457                 const _: () = {
458                     assert!(
459                         1 == < Flag2 as wasmtime::component::ComponentType >::SIZE32
460                     );
461                     assert!(
462                         1 == < Flag2 as wasmtime::component::ComponentType >::ALIGN32
463                     );
464                 };
465                 wasmtime::component::flags!(
466                     Flag4 { #[component(name = "b0")] const B0; #[component(name = "b1")]
467                     const B1; #[component(name = "b2")] const B2; #[component(name =
468                     "b3")] const B3; }
469                 );
470                 const _: () = {
471                     assert!(
472                         1 == < Flag4 as wasmtime::component::ComponentType >::SIZE32
473                     );
474                     assert!(
475                         1 == < Flag4 as wasmtime::component::ComponentType >::ALIGN32
476                     );
477                 };
478                 wasmtime::component::flags!(
479                     Flag8 { #[component(name = "b0")] const B0; #[component(name = "b1")]
480                     const B1; #[component(name = "b2")] const B2; #[component(name =
481                     "b3")] const B3; #[component(name = "b4")] const B4; #[component(name
482                     = "b5")] const B5; #[component(name = "b6")] const B6;
483                     #[component(name = "b7")] const B7; }
484                 );
485                 const _: () = {
486                     assert!(
487                         1 == < Flag8 as wasmtime::component::ComponentType >::SIZE32
488                     );
489                     assert!(
490                         1 == < Flag8 as wasmtime::component::ComponentType >::ALIGN32
491                     );
492                 };
493                 wasmtime::component::flags!(
494                     Flag16 { #[component(name = "b0")] const B0; #[component(name =
495                     "b1")] const B1; #[component(name = "b2")] const B2; #[component(name
496                     = "b3")] const B3; #[component(name = "b4")] const B4;
497                     #[component(name = "b5")] const B5; #[component(name = "b6")] const
498                     B6; #[component(name = "b7")] const B7; #[component(name = "b8")]
499                     const B8; #[component(name = "b9")] const B9; #[component(name =
500                     "b10")] const B10; #[component(name = "b11")] const B11;
501                     #[component(name = "b12")] const B12; #[component(name = "b13")]
502                     const B13; #[component(name = "b14")] const B14; #[component(name =
503                     "b15")] const B15; }
504                 );
505                 const _: () = {
506                     assert!(
507                         2 == < Flag16 as wasmtime::component::ComponentType >::SIZE32
508                     );
509                     assert!(
510                         2 == < Flag16 as wasmtime::component::ComponentType >::ALIGN32
511                     );
512                 };
513                 wasmtime::component::flags!(
514                     Flag32 { #[component(name = "b0")] const B0; #[component(name =
515                     "b1")] const B1; #[component(name = "b2")] const B2; #[component(name
516                     = "b3")] const B3; #[component(name = "b4")] const B4;
517                     #[component(name = "b5")] const B5; #[component(name = "b6")] const
518                     B6; #[component(name = "b7")] const B7; #[component(name = "b8")]
519                     const B8; #[component(name = "b9")] const B9; #[component(name =
520                     "b10")] const B10; #[component(name = "b11")] const B11;
521                     #[component(name = "b12")] const B12; #[component(name = "b13")]
522                     const B13; #[component(name = "b14")] const B14; #[component(name =
523                     "b15")] const B15; #[component(name = "b16")] const B16;
524                     #[component(name = "b17")] const B17; #[component(name = "b18")]
525                     const B18; #[component(name = "b19")] const B19; #[component(name =
526                     "b20")] const B20; #[component(name = "b21")] const B21;
527                     #[component(name = "b22")] const B22; #[component(name = "b23")]
528                     const B23; #[component(name = "b24")] const B24; #[component(name =
529                     "b25")] const B25; #[component(name = "b26")] const B26;
530                     #[component(name = "b27")] const B27; #[component(name = "b28")]
531                     const B28; #[component(name = "b29")] const B29; #[component(name =
532                     "b30")] const B30; #[component(name = "b31")] const B31; }
533                 );
534                 const _: () = {
535                     assert!(
536                         4 == < Flag32 as wasmtime::component::ComponentType >::SIZE32
537                     );
538                     assert!(
539                         4 == < Flag32 as wasmtime::component::ComponentType >::ALIGN32
540                     );
541                 };
542                 wasmtime::component::flags!(
543                     Flag64 { #[component(name = "b0")] const B0; #[component(name =
544                     "b1")] const B1; #[component(name = "b2")] const B2; #[component(name
545                     = "b3")] const B3; #[component(name = "b4")] const B4;
546                     #[component(name = "b5")] const B5; #[component(name = "b6")] const
547                     B6; #[component(name = "b7")] const B7; #[component(name = "b8")]
548                     const B8; #[component(name = "b9")] const B9; #[component(name =
549                     "b10")] const B10; #[component(name = "b11")] const B11;
550                     #[component(name = "b12")] const B12; #[component(name = "b13")]
551                     const B13; #[component(name = "b14")] const B14; #[component(name =
552                     "b15")] const B15; #[component(name = "b16")] const B16;
553                     #[component(name = "b17")] const B17; #[component(name = "b18")]
554                     const B18; #[component(name = "b19")] const B19; #[component(name =
555                     "b20")] const B20; #[component(name = "b21")] const B21;
556                     #[component(name = "b22")] const B22; #[component(name = "b23")]
557                     const B23; #[component(name = "b24")] const B24; #[component(name =
558                     "b25")] const B25; #[component(name = "b26")] const B26;
559                     #[component(name = "b27")] const B27; #[component(name = "b28")]
560                     const B28; #[component(name = "b29")] const B29; #[component(name =
561                     "b30")] const B30; #[component(name = "b31")] const B31;
562                     #[component(name = "b32")] const B32; #[component(name = "b33")]
563                     const B33; #[component(name = "b34")] const B34; #[component(name =
564                     "b35")] const B35; #[component(name = "b36")] const B36;
565                     #[component(name = "b37")] const B37; #[component(name = "b38")]
566                     const B38; #[component(name = "b39")] const B39; #[component(name =
567                     "b40")] const B40; #[component(name = "b41")] const B41;
568                     #[component(name = "b42")] const B42; #[component(name = "b43")]
569                     const B43; #[component(name = "b44")] const B44; #[component(name =
570                     "b45")] const B45; #[component(name = "b46")] const B46;
571                     #[component(name = "b47")] const B47; #[component(name = "b48")]
572                     const B48; #[component(name = "b49")] const B49; #[component(name =
573                     "b50")] const B50; #[component(name = "b51")] const B51;
574                     #[component(name = "b52")] const B52; #[component(name = "b53")]
575                     const B53; #[component(name = "b54")] const B54; #[component(name =
576                     "b55")] const B55; #[component(name = "b56")] const B56;
577                     #[component(name = "b57")] const B57; #[component(name = "b58")]
578                     const B58; #[component(name = "b59")] const B59; #[component(name =
579                     "b60")] const B60; #[component(name = "b61")] const B61;
580                     #[component(name = "b62")] const B62; #[component(name = "b63")]
581                     const B63; }
582                 );
583                 const _: () = {
584                     assert!(
585                         8 == < Flag64 as wasmtime::component::ComponentType >::SIZE32
586                     );
587                     assert!(
588                         4 == < Flag64 as wasmtime::component::ComponentType >::ALIGN32
589                     );
590                 };
591                 #[derive(Clone)]
592                 pub struct Guest {
593                     roundtrip_flag1: wasmtime::component::Func,
594                     roundtrip_flag2: wasmtime::component::Func,
595                     roundtrip_flag4: wasmtime::component::Func,
596                     roundtrip_flag8: wasmtime::component::Func,
597                     roundtrip_flag16: wasmtime::component::Func,
598                     roundtrip_flag32: wasmtime::component::Func,
599                     roundtrip_flag64: wasmtime::component::Func,
600                 }
601                 #[derive(Clone)]
602                 pub struct GuestIndices {
603                     roundtrip_flag1: wasmtime::component::ComponentExportIndex,
604                     roundtrip_flag2: wasmtime::component::ComponentExportIndex,
605                     roundtrip_flag4: wasmtime::component::ComponentExportIndex,
606                     roundtrip_flag8: wasmtime::component::ComponentExportIndex,
607                     roundtrip_flag16: wasmtime::component::ComponentExportIndex,
608                     roundtrip_flag32: wasmtime::component::ComponentExportIndex,
609                     roundtrip_flag64: wasmtime::component::ComponentExportIndex,
610                 }
611                 impl GuestIndices {
612                     /// Constructor for [`GuestIndices`] which takes a
613                     /// [`Component`](wasmtime::component::Component) as input and can be executed
614                     /// before instantiation.
615                     ///
616                     /// This constructor can be used to front-load string lookups to find exports
617                     /// within a component.
new<_T>( _instance_pre: &wasmtime::component::InstancePre<_T>, ) -> wasmtime::Result<GuestIndices>618                     pub fn new<_T>(
619                         _instance_pre: &wasmtime::component::InstancePre<_T>,
620                     ) -> wasmtime::Result<GuestIndices> {
621                         let instance = _instance_pre
622                             .component()
623                             .get_export_index(None, "foo:foo/flegs")
624                             .ok_or_else(|| {
625                                 wasmtime::format_err!(
626                                     "no exported instance named `foo:foo/flegs`"
627                                 )
628                             })?;
629                         let mut lookup = move |name| {
630                             _instance_pre
631                                 .component()
632                                 .get_export_index(Some(&instance), name)
633                                 .ok_or_else(|| {
634                                     wasmtime::format_err!(
635                                         "instance export `foo:foo/flegs` does \
636                               not have export `{name}`"
637                                     )
638                                 })
639                         };
640                         let _ = &mut lookup;
641                         let roundtrip_flag1 = lookup("roundtrip-flag1")?;
642                         let roundtrip_flag2 = lookup("roundtrip-flag2")?;
643                         let roundtrip_flag4 = lookup("roundtrip-flag4")?;
644                         let roundtrip_flag8 = lookup("roundtrip-flag8")?;
645                         let roundtrip_flag16 = lookup("roundtrip-flag16")?;
646                         let roundtrip_flag32 = lookup("roundtrip-flag32")?;
647                         let roundtrip_flag64 = lookup("roundtrip-flag64")?;
648                         Ok(GuestIndices {
649                             roundtrip_flag1,
650                             roundtrip_flag2,
651                             roundtrip_flag4,
652                             roundtrip_flag8,
653                             roundtrip_flag16,
654                             roundtrip_flag32,
655                             roundtrip_flag64,
656                         })
657                     }
load( &self, mut store: impl wasmtime::AsContextMut, instance: &wasmtime::component::Instance, ) -> wasmtime::Result<Guest>658                     pub fn load(
659                         &self,
660                         mut store: impl wasmtime::AsContextMut,
661                         instance: &wasmtime::component::Instance,
662                     ) -> wasmtime::Result<Guest> {
663                         let _instance = instance;
664                         let _instance_pre = _instance.instance_pre(&store);
665                         let _instance_type = _instance_pre.instance_type();
666                         let mut store = store.as_context_mut();
667                         let _ = &mut store;
668                         let roundtrip_flag1 = *_instance
669                             .get_typed_func::<
670                                 (Flag1,),
671                                 (Flag1,),
672                             >(&mut store, &self.roundtrip_flag1)?
673                             .func();
674                         let roundtrip_flag2 = *_instance
675                             .get_typed_func::<
676                                 (Flag2,),
677                                 (Flag2,),
678                             >(&mut store, &self.roundtrip_flag2)?
679                             .func();
680                         let roundtrip_flag4 = *_instance
681                             .get_typed_func::<
682                                 (Flag4,),
683                                 (Flag4,),
684                             >(&mut store, &self.roundtrip_flag4)?
685                             .func();
686                         let roundtrip_flag8 = *_instance
687                             .get_typed_func::<
688                                 (Flag8,),
689                                 (Flag8,),
690                             >(&mut store, &self.roundtrip_flag8)?
691                             .func();
692                         let roundtrip_flag16 = *_instance
693                             .get_typed_func::<
694                                 (Flag16,),
695                                 (Flag16,),
696                             >(&mut store, &self.roundtrip_flag16)?
697                             .func();
698                         let roundtrip_flag32 = *_instance
699                             .get_typed_func::<
700                                 (Flag32,),
701                                 (Flag32,),
702                             >(&mut store, &self.roundtrip_flag32)?
703                             .func();
704                         let roundtrip_flag64 = *_instance
705                             .get_typed_func::<
706                                 (Flag64,),
707                                 (Flag64,),
708                             >(&mut store, &self.roundtrip_flag64)?
709                             .func();
710                         Ok(Guest {
711                             roundtrip_flag1,
712                             roundtrip_flag2,
713                             roundtrip_flag4,
714                             roundtrip_flag8,
715                             roundtrip_flag16,
716                             roundtrip_flag32,
717                             roundtrip_flag64,
718                         })
719                     }
720                 }
721                 impl Guest {
call_roundtrip_flag1<S: wasmtime::AsContextMut>( &self, mut store: S, arg0: Flag1, ) -> wasmtime::Result<Flag1>722                     pub fn call_roundtrip_flag1<S: wasmtime::AsContextMut>(
723                         &self,
724                         mut store: S,
725                         arg0: Flag1,
726                     ) -> wasmtime::Result<Flag1> {
727                         let callee = unsafe {
728                             wasmtime::component::TypedFunc::<
729                                 (Flag1,),
730                                 (Flag1,),
731                             >::new_unchecked(self.roundtrip_flag1)
732                         };
733                         let (ret0,) = callee.call(store.as_context_mut(), (arg0,))?;
734                         Ok(ret0)
735                     }
call_roundtrip_flag2<S: wasmtime::AsContextMut>( &self, mut store: S, arg0: Flag2, ) -> wasmtime::Result<Flag2>736                     pub fn call_roundtrip_flag2<S: wasmtime::AsContextMut>(
737                         &self,
738                         mut store: S,
739                         arg0: Flag2,
740                     ) -> wasmtime::Result<Flag2> {
741                         let callee = unsafe {
742                             wasmtime::component::TypedFunc::<
743                                 (Flag2,),
744                                 (Flag2,),
745                             >::new_unchecked(self.roundtrip_flag2)
746                         };
747                         let (ret0,) = callee.call(store.as_context_mut(), (arg0,))?;
748                         Ok(ret0)
749                     }
call_roundtrip_flag4<S: wasmtime::AsContextMut>( &self, mut store: S, arg0: Flag4, ) -> wasmtime::Result<Flag4>750                     pub fn call_roundtrip_flag4<S: wasmtime::AsContextMut>(
751                         &self,
752                         mut store: S,
753                         arg0: Flag4,
754                     ) -> wasmtime::Result<Flag4> {
755                         let callee = unsafe {
756                             wasmtime::component::TypedFunc::<
757                                 (Flag4,),
758                                 (Flag4,),
759                             >::new_unchecked(self.roundtrip_flag4)
760                         };
761                         let (ret0,) = callee.call(store.as_context_mut(), (arg0,))?;
762                         Ok(ret0)
763                     }
call_roundtrip_flag8<S: wasmtime::AsContextMut>( &self, mut store: S, arg0: Flag8, ) -> wasmtime::Result<Flag8>764                     pub fn call_roundtrip_flag8<S: wasmtime::AsContextMut>(
765                         &self,
766                         mut store: S,
767                         arg0: Flag8,
768                     ) -> wasmtime::Result<Flag8> {
769                         let callee = unsafe {
770                             wasmtime::component::TypedFunc::<
771                                 (Flag8,),
772                                 (Flag8,),
773                             >::new_unchecked(self.roundtrip_flag8)
774                         };
775                         let (ret0,) = callee.call(store.as_context_mut(), (arg0,))?;
776                         Ok(ret0)
777                     }
call_roundtrip_flag16<S: wasmtime::AsContextMut>( &self, mut store: S, arg0: Flag16, ) -> wasmtime::Result<Flag16>778                     pub fn call_roundtrip_flag16<S: wasmtime::AsContextMut>(
779                         &self,
780                         mut store: S,
781                         arg0: Flag16,
782                     ) -> wasmtime::Result<Flag16> {
783                         let callee = unsafe {
784                             wasmtime::component::TypedFunc::<
785                                 (Flag16,),
786                                 (Flag16,),
787                             >::new_unchecked(self.roundtrip_flag16)
788                         };
789                         let (ret0,) = callee.call(store.as_context_mut(), (arg0,))?;
790                         Ok(ret0)
791                     }
call_roundtrip_flag32<S: wasmtime::AsContextMut>( &self, mut store: S, arg0: Flag32, ) -> wasmtime::Result<Flag32>792                     pub fn call_roundtrip_flag32<S: wasmtime::AsContextMut>(
793                         &self,
794                         mut store: S,
795                         arg0: Flag32,
796                     ) -> wasmtime::Result<Flag32> {
797                         let callee = unsafe {
798                             wasmtime::component::TypedFunc::<
799                                 (Flag32,),
800                                 (Flag32,),
801                             >::new_unchecked(self.roundtrip_flag32)
802                         };
803                         let (ret0,) = callee.call(store.as_context_mut(), (arg0,))?;
804                         Ok(ret0)
805                     }
call_roundtrip_flag64<S: wasmtime::AsContextMut>( &self, mut store: S, arg0: Flag64, ) -> wasmtime::Result<Flag64>806                     pub fn call_roundtrip_flag64<S: wasmtime::AsContextMut>(
807                         &self,
808                         mut store: S,
809                         arg0: Flag64,
810                     ) -> wasmtime::Result<Flag64> {
811                         let callee = unsafe {
812                             wasmtime::component::TypedFunc::<
813                                 (Flag64,),
814                                 (Flag64,),
815                             >::new_unchecked(self.roundtrip_flag64)
816                         };
817                         let (ret0,) = callee.call(store.as_context_mut(), (arg0,))?;
818                         Ok(ret0)
819                     }
820                 }
821             }
822         }
823     }
824 }
825