1 pub enum WorldResource {}
2 pub trait HostWorldResourceWithStore: wasmtime::component::HasData + Send {
drop<T>( accessor: &wasmtime::component::Accessor<T, Self>, rep: wasmtime::component::Resource<WorldResource>, ) -> impl ::core::future::Future<Output = wasmtime::Result<()>> + Send where Self: Sized3     fn drop<T>(
4         accessor: &wasmtime::component::Accessor<T, Self>,
5         rep: wasmtime::component::Resource<WorldResource>,
6     ) -> impl ::core::future::Future<Output = wasmtime::Result<()>> + Send
7     where
8         Self: Sized;
new<T: Send>( accessor: &wasmtime::component::Accessor<T, Self>, ) -> impl ::core::future::Future< Output = wasmtime::component::Resource<WorldResource>, > + Send9     fn new<T: Send>(
10         accessor: &wasmtime::component::Accessor<T, Self>,
11     ) -> impl ::core::future::Future<
12         Output = wasmtime::component::Resource<WorldResource>,
13     > + Send;
foo<T: Send>( accessor: &wasmtime::component::Accessor<T, Self>, self_: wasmtime::component::Resource<WorldResource>, ) -> impl ::core::future::Future<Output = ()> + Send14     fn foo<T: Send>(
15         accessor: &wasmtime::component::Accessor<T, Self>,
16         self_: wasmtime::component::Resource<WorldResource>,
17     ) -> impl ::core::future::Future<Output = ()> + Send;
static_foo<T: Send>( accessor: &wasmtime::component::Accessor<T, Self>, ) -> impl ::core::future::Future<Output = ()> + Send18     fn static_foo<T: Send>(
19         accessor: &wasmtime::component::Accessor<T, Self>,
20     ) -> impl ::core::future::Future<Output = ()> + Send;
21 }
22 pub trait HostWorldResource: Send {}
23 impl<_T: HostWorldResource + ?Sized + Send> HostWorldResource for &mut _T {}
24 /// Auto-generated bindings for a pre-instantiated version of a
25 /// component which implements the world `the-world`.
26 ///
27 /// This structure is created through [`TheWorldPre::new`] which
28 /// takes a [`InstancePre`](wasmtime::component::InstancePre) that
29 /// has been created through a [`Linker`](wasmtime::component::Linker).
30 ///
31 /// For more information see [`TheWorld`] as well.
32 pub struct TheWorldPre<T: 'static> {
33     instance_pre: wasmtime::component::InstancePre<T>,
34     indices: TheWorldIndices,
35 }
36 impl<T: 'static> Clone for TheWorldPre<T> {
clone(&self) -> Self37     fn clone(&self) -> Self {
38         Self {
39             instance_pre: self.instance_pre.clone(),
40             indices: self.indices.clone(),
41         }
42     }
43 }
44 impl<_T: 'static> TheWorldPre<_T> {
45     /// Creates a new copy of `TheWorldPre` bindings which can then
46     /// be used to instantiate into a particular store.
47     ///
48     /// This method may fail if the component behind `instance_pre`
49     /// does not have the required exports.
new( instance_pre: wasmtime::component::InstancePre<_T>, ) -> wasmtime::Result<Self>50     pub fn new(
51         instance_pre: wasmtime::component::InstancePre<_T>,
52     ) -> wasmtime::Result<Self> {
53         let indices = TheWorldIndices::new(&instance_pre)?;
54         Ok(Self { instance_pre, indices })
55     }
engine(&self) -> &wasmtime::Engine56     pub fn engine(&self) -> &wasmtime::Engine {
57         self.instance_pre.engine()
58     }
instance_pre(&self) -> &wasmtime::component::InstancePre<_T>59     pub fn instance_pre(&self) -> &wasmtime::component::InstancePre<_T> {
60         &self.instance_pre
61     }
62     /// Instantiates a new instance of [`TheWorld`] within the
63     /// `store` provided.
64     ///
65     /// This function will use `self` as the pre-instantiated
66     /// instance to perform instantiation. Afterwards the preloaded
67     /// indices in `self` are used to lookup all exports on the
68     /// resulting instance.
instantiate( &self, mut store: impl wasmtime::AsContextMut<Data = _T>, ) -> wasmtime::Result<TheWorld>69     pub fn instantiate(
70         &self,
71         mut store: impl wasmtime::AsContextMut<Data = _T>,
72     ) -> wasmtime::Result<TheWorld> {
73         let mut store = store.as_context_mut();
74         let instance = self.instance_pre.instantiate(&mut store)?;
75         self.indices.load(&mut store, &instance)
76     }
77 }
78 impl<_T: Send + 'static> TheWorldPre<_T> {
79     /// Same as [`Self::instantiate`], except with `async`.
instantiate_async( &self, mut store: impl wasmtime::AsContextMut<Data = _T>, ) -> wasmtime::Result<TheWorld>80     pub async fn instantiate_async(
81         &self,
82         mut store: impl wasmtime::AsContextMut<Data = _T>,
83     ) -> wasmtime::Result<TheWorld> {
84         let mut store = store.as_context_mut();
85         let instance = self.instance_pre.instantiate_async(&mut store).await?;
86         self.indices.load(&mut store, &instance)
87     }
88 }
89 /// Auto-generated bindings for index of the exports of
90 /// `the-world`.
91 ///
92 /// This is an implementation detail of [`TheWorldPre`] and can
93 /// be constructed if needed as well.
94 ///
95 /// For more information see [`TheWorld`] as well.
96 #[derive(Clone)]
97 pub struct TheWorldIndices {
98     interface1: exports::foo::foo::uses_resource_transitively::GuestIndices,
99     some_world_func2: wasmtime::component::ComponentExportIndex,
100 }
101 /// Auto-generated bindings for an instance a component which
102 /// implements the world `the-world`.
103 ///
104 /// This structure can be created through a number of means
105 /// depending on your requirements and what you have on hand:
106 ///
107 /// * The most convenient way is to use
108 ///   [`TheWorld::instantiate`] which only needs a
109 ///   [`Store`], [`Component`], and [`Linker`].
110 ///
111 /// * Alternatively you can create a [`TheWorldPre`] ahead of
112 ///   time with a [`Component`] to front-load string lookups
113 ///   of exports once instead of per-instantiation. This
114 ///   method then uses [`TheWorldPre::instantiate`] to
115 ///   create a [`TheWorld`].
116 ///
117 /// * If you've instantiated the instance yourself already
118 ///   then you can use [`TheWorld::new`].
119 ///
120 /// These methods are all equivalent to one another and move
121 /// around the tradeoff of what work is performed when.
122 ///
123 /// [`Store`]: wasmtime::Store
124 /// [`Component`]: wasmtime::component::Component
125 /// [`Linker`]: wasmtime::component::Linker
126 pub struct TheWorld {
127     interface1: exports::foo::foo::uses_resource_transitively::Guest,
128     some_world_func2: wasmtime::component::Func,
129 }
130 pub trait TheWorldImportsWithStore: wasmtime::component::HasData + HostWorldResourceWithStore + Send {
some_world_func<T: Send>( accessor: &wasmtime::component::Accessor<T, Self>, ) -> impl ::core::future::Future< Output = wasmtime::component::Resource<WorldResource>, > + Send131     fn some_world_func<T: Send>(
132         accessor: &wasmtime::component::Accessor<T, Self>,
133     ) -> impl ::core::future::Future<
134         Output = wasmtime::component::Resource<WorldResource>,
135     > + Send;
136 }
137 pub trait TheWorldImports: HostWorldResource + Send {}
138 impl<_T: TheWorldImports + ?Sized + Send> TheWorldImports for &mut _T {}
139 const _: () = {
140     impl TheWorldIndices {
141         /// Creates a new copy of `TheWorldIndices` bindings which can then
142         /// be used to instantiate into a particular store.
143         ///
144         /// This method may fail if the component does not have the
145         /// required exports.
new<_T>( _instance_pre: &wasmtime::component::InstancePre<_T>, ) -> wasmtime::Result<Self>146         pub fn new<_T>(
147             _instance_pre: &wasmtime::component::InstancePre<_T>,
148         ) -> wasmtime::Result<Self> {
149             let _component = _instance_pre.component();
150             let _instance_type = _instance_pre.instance_type();
151             let interface1 = exports::foo::foo::uses_resource_transitively::GuestIndices::new(
152                 _instance_pre,
153             )?;
154             let some_world_func2 = {
155                 let (item, index) = _component
156                     .get_export(None, "some-world-func2")
157                     .ok_or_else(|| {
158                         wasmtime::format_err!("no export `some-world-func2` found")
159                     })?;
160                 match item {
161                     wasmtime::component::types::ComponentItem::ComponentFunc(func) => {
162                         wasmtime::error::Context::context(
163                             func
164                                 .typecheck::<
165                                     (),
166                                     (wasmtime::component::Resource<WorldResource>,),
167                                 >(&_instance_type),
168                             "type-checking export func `some-world-func2`",
169                         )?;
170                         index
171                     }
172                     _ => {
173                         Err(
174                             wasmtime::format_err!(
175                                 "export `some-world-func2` is not a function"
176                             ),
177                         )?
178                     }
179                 }
180             };
181             Ok(TheWorldIndices {
182                 interface1,
183                 some_world_func2,
184             })
185         }
186         /// Uses the indices stored in `self` to load an instance
187         /// of [`TheWorld`] from the instance provided.
188         ///
189         /// Note that at this time this method will additionally
190         /// perform type-checks of all exports.
load( &self, mut store: impl wasmtime::AsContextMut, instance: &wasmtime::component::Instance, ) -> wasmtime::Result<TheWorld>191         pub fn load(
192             &self,
193             mut store: impl wasmtime::AsContextMut,
194             instance: &wasmtime::component::Instance,
195         ) -> wasmtime::Result<TheWorld> {
196             let _ = &mut store;
197             let _instance = instance;
198             let interface1 = self.interface1.load(&mut store, &_instance)?;
199             let some_world_func2 = *_instance
200                 .get_typed_func::<
201                     (),
202                     (wasmtime::component::Resource<WorldResource>,),
203                 >(&mut store, &self.some_world_func2)?
204                 .func();
205             Ok(TheWorld {
206                 interface1,
207                 some_world_func2,
208             })
209         }
210     }
211     impl TheWorld {
212         /// Convenience wrapper around [`TheWorldPre::new`] and
213         /// [`TheWorldPre::instantiate`].
instantiate<_T>( store: impl wasmtime::AsContextMut<Data = _T>, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, ) -> wasmtime::Result<TheWorld>214         pub fn instantiate<_T>(
215             store: impl wasmtime::AsContextMut<Data = _T>,
216             component: &wasmtime::component::Component,
217             linker: &wasmtime::component::Linker<_T>,
218         ) -> wasmtime::Result<TheWorld> {
219             let pre = linker.instantiate_pre(component)?;
220             TheWorldPre::new(pre)?.instantiate(store)
221         }
222         /// Convenience wrapper around [`TheWorldIndices::new`] and
223         /// [`TheWorldIndices::load`].
new( mut store: impl wasmtime::AsContextMut, instance: &wasmtime::component::Instance, ) -> wasmtime::Result<TheWorld>224         pub fn new(
225             mut store: impl wasmtime::AsContextMut,
226             instance: &wasmtime::component::Instance,
227         ) -> wasmtime::Result<TheWorld> {
228             let indices = TheWorldIndices::new(&instance.instance_pre(&store))?;
229             indices.load(&mut store, instance)
230         }
231         /// Convenience wrapper around [`TheWorldPre::new`] and
232         /// [`TheWorldPre::instantiate_async`].
instantiate_async<_T>( store: impl wasmtime::AsContextMut<Data = _T>, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, ) -> wasmtime::Result<TheWorld> where _T: Send,233         pub async fn instantiate_async<_T>(
234             store: impl wasmtime::AsContextMut<Data = _T>,
235             component: &wasmtime::component::Component,
236             linker: &wasmtime::component::Linker<_T>,
237         ) -> wasmtime::Result<TheWorld>
238         where
239             _T: Send,
240         {
241             let pre = linker.instantiate_pre(component)?;
242             TheWorldPre::new(pre)?.instantiate_async(store).await
243         }
add_to_linker_imports<T, D>( linker: &mut wasmtime::component::Linker<T>, host_getter: fn(&mut T) -> D::Data<'_>, ) -> wasmtime::Result<()> where D: TheWorldImportsWithStore, for<'a> D::Data<'a>: TheWorldImports, T: 'static + Send,244         pub fn add_to_linker_imports<T, D>(
245             linker: &mut wasmtime::component::Linker<T>,
246             host_getter: fn(&mut T) -> D::Data<'_>,
247         ) -> wasmtime::Result<()>
248         where
249             D: TheWorldImportsWithStore,
250             for<'a> D::Data<'a>: TheWorldImports,
251             T: 'static + Send,
252         {
253             let mut linker = linker.root();
254             linker
255                 .resource_concurrent(
256                     "world-resource",
257                     wasmtime::component::ResourceType::host::<WorldResource>(),
258                     move |caller: &wasmtime::component::Accessor<T>, rep| {
259                         wasmtime::component::__internal::Box::pin(async move {
260                             let accessor = &caller.with_getter(host_getter);
261                             wasmtime::ToWasmtimeResult::to_wasmtime_result(
262                                 HostWorldResourceWithStore::drop(
263                                         accessor,
264                                         wasmtime::component::Resource::new_own(rep),
265                                     )
266                                     .await,
267                             )
268                         })
269                     },
270                 )?;
271             linker
272                 .func_wrap_concurrent(
273                     "some-world-func",
274                     move |caller: &wasmtime::component::Accessor<T>, (): ()| {
275                         wasmtime::component::__internal::Box::pin(async move {
276                             let host = &caller.with_getter(host_getter);
277                             let r = <D as TheWorldImportsWithStore>::some_world_func(
278                                     host,
279                                 )
280                                 .await;
281                             Ok((r,))
282                         })
283                     },
284                 )?;
285             linker
286                 .func_wrap_concurrent(
287                     "[constructor]world-resource",
288                     move |caller: &wasmtime::component::Accessor<T>, (): ()| {
289                         wasmtime::component::__internal::Box::pin(async move {
290                             let host = &caller.with_getter(host_getter);
291                             let r = <D as HostWorldResourceWithStore>::new(host).await;
292                             Ok((r,))
293                         })
294                     },
295                 )?;
296             linker
297                 .func_wrap_concurrent(
298                     "[method]world-resource.foo",
299                     move |
300                         caller: &wasmtime::component::Accessor<T>,
301                         (arg0,): (wasmtime::component::Resource<WorldResource>,)|
302                     {
303                         wasmtime::component::__internal::Box::pin(async move {
304                             let host = &caller.with_getter(host_getter);
305                             let r = <D as HostWorldResourceWithStore>::foo(host, arg0)
306                                 .await;
307                             Ok(r)
308                         })
309                     },
310                 )?;
311             linker
312                 .func_wrap_concurrent(
313                     "[static]world-resource.static-foo",
314                     move |caller: &wasmtime::component::Accessor<T>, (): ()| {
315                         wasmtime::component::__internal::Box::pin(async move {
316                             let host = &caller.with_getter(host_getter);
317                             let r = <D as HostWorldResourceWithStore>::static_foo(host)
318                                 .await;
319                             Ok(r)
320                         })
321                     },
322                 )?;
323             Ok(())
324         }
add_to_linker<T, D>( linker: &mut wasmtime::component::Linker<T>, host_getter: fn(&mut T) -> D::Data<'_>, ) -> wasmtime::Result<()> where D: foo::foo::resources::HostWithStore + foo::foo::long_use_chain1::HostWithStore + foo::foo::long_use_chain2::HostWithStore + foo::foo::long_use_chain3::HostWithStore + foo::foo::long_use_chain4::HostWithStore + foo::foo::transitive_interface_with_resource::HostWithStore + TheWorldImportsWithStore + Send, for<'a> D::Data< 'a, >: foo::foo::resources::Host + foo::foo::long_use_chain1::Host + foo::foo::long_use_chain2::Host + foo::foo::long_use_chain3::Host + foo::foo::long_use_chain4::Host + foo::foo::transitive_interface_with_resource::Host + TheWorldImports + Send, T: 'static + Send,325         pub fn add_to_linker<T, D>(
326             linker: &mut wasmtime::component::Linker<T>,
327             host_getter: fn(&mut T) -> D::Data<'_>,
328         ) -> wasmtime::Result<()>
329         where
330             D: foo::foo::resources::HostWithStore
331                 + foo::foo::long_use_chain1::HostWithStore
332                 + foo::foo::long_use_chain2::HostWithStore
333                 + foo::foo::long_use_chain3::HostWithStore
334                 + foo::foo::long_use_chain4::HostWithStore
335                 + foo::foo::transitive_interface_with_resource::HostWithStore
336                 + TheWorldImportsWithStore + Send,
337             for<'a> D::Data<
338                 'a,
339             >: foo::foo::resources::Host + foo::foo::long_use_chain1::Host
340                 + foo::foo::long_use_chain2::Host + foo::foo::long_use_chain3::Host
341                 + foo::foo::long_use_chain4::Host
342                 + foo::foo::transitive_interface_with_resource::Host + TheWorldImports
343                 + Send,
344             T: 'static + Send,
345         {
346             Self::add_to_linker_imports::<T, D>(linker, host_getter)?;
347             foo::foo::resources::add_to_linker::<T, D>(linker, host_getter)?;
348             foo::foo::long_use_chain1::add_to_linker::<T, D>(linker, host_getter)?;
349             foo::foo::long_use_chain2::add_to_linker::<T, D>(linker, host_getter)?;
350             foo::foo::long_use_chain3::add_to_linker::<T, D>(linker, host_getter)?;
351             foo::foo::long_use_chain4::add_to_linker::<T, D>(linker, host_getter)?;
352             foo::foo::transitive_interface_with_resource::add_to_linker::<
353                 T,
354                 D,
355             >(linker, host_getter)?;
356             Ok(())
357         }
call_some_world_func2<_T, _D>( &self, accessor: &wasmtime::component::Accessor<_T, _D>, ) -> wasmtime::Result<wasmtime::component::Resource<WorldResource>> where _T: Send, _D: wasmtime::component::HasData,358         pub async fn call_some_world_func2<_T, _D>(
359             &self,
360             accessor: &wasmtime::component::Accessor<_T, _D>,
361         ) -> wasmtime::Result<wasmtime::component::Resource<WorldResource>>
362         where
363             _T: Send,
364             _D: wasmtime::component::HasData,
365         {
366             let callee = unsafe {
367                 wasmtime::component::TypedFunc::<
368                     (),
369                     (wasmtime::component::Resource<WorldResource>,),
370                 >::new_unchecked(self.some_world_func2)
371             };
372             let (ret0,) = callee.call_concurrent(accessor, ()).await?;
373             Ok(ret0)
374         }
foo_foo_uses_resource_transitively( &self, ) -> &exports::foo::foo::uses_resource_transitively::Guest375         pub fn foo_foo_uses_resource_transitively(
376             &self,
377         ) -> &exports::foo::foo::uses_resource_transitively::Guest {
378             &self.interface1
379         }
380     }
381 };
382 pub mod foo {
383     pub mod foo {
384         #[allow(clippy::all)]
385         pub mod resources {
386             #[allow(unused_imports)]
387             use wasmtime::component::__internal::Box;
388             pub enum Bar {}
389             pub trait HostBarWithStore: wasmtime::component::HasData + Send {
drop<T>( accessor: &wasmtime::component::Accessor<T, Self>, rep: wasmtime::component::Resource<Bar>, ) -> impl ::core::future::Future<Output = wasmtime::Result<()>> + Send where Self: Sized390                 fn drop<T>(
391                     accessor: &wasmtime::component::Accessor<T, Self>,
392                     rep: wasmtime::component::Resource<Bar>,
393                 ) -> impl ::core::future::Future<Output = wasmtime::Result<()>> + Send
394                 where
395                     Self: Sized;
new<T: Send>( accessor: &wasmtime::component::Accessor<T, Self>, ) -> impl ::core::future::Future< Output = wasmtime::component::Resource<Bar>, > + Send396                 fn new<T: Send>(
397                     accessor: &wasmtime::component::Accessor<T, Self>,
398                 ) -> impl ::core::future::Future<
399                     Output = wasmtime::component::Resource<Bar>,
400                 > + Send;
static_a<T: Send>( accessor: &wasmtime::component::Accessor<T, Self>, ) -> impl ::core::future::Future<Output = u32> + Send401                 fn static_a<T: Send>(
402                     accessor: &wasmtime::component::Accessor<T, Self>,
403                 ) -> impl ::core::future::Future<Output = u32> + Send;
method_a<T: Send>( accessor: &wasmtime::component::Accessor<T, Self>, self_: wasmtime::component::Resource<Bar>, ) -> impl ::core::future::Future<Output = u32> + Send404                 fn method_a<T: Send>(
405                     accessor: &wasmtime::component::Accessor<T, Self>,
406                     self_: wasmtime::component::Resource<Bar>,
407                 ) -> impl ::core::future::Future<Output = u32> + Send;
408             }
409             pub trait HostBar: Send {}
410             impl<_T: HostBar + ?Sized + Send> HostBar for &mut _T {}
411             #[derive(wasmtime::component::ComponentType)]
412             #[derive(wasmtime::component::Lift)]
413             #[derive(wasmtime::component::Lower)]
414             #[component(record)]
415             pub struct NestedOwn {
416                 #[component(name = "nested-bar")]
417                 pub nested_bar: wasmtime::component::Resource<Bar>,
418             }
419             impl core::fmt::Debug for NestedOwn {
fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result420                 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
421                     f.debug_struct("NestedOwn")
422                         .field("nested-bar", &self.nested_bar)
423                         .finish()
424                 }
425             }
426             const _: () = {
427                 assert!(
428                     4 == < NestedOwn as wasmtime::component::ComponentType >::SIZE32
429                 );
430                 assert!(
431                     4 == < NestedOwn as wasmtime::component::ComponentType >::ALIGN32
432                 );
433             };
434             #[derive(wasmtime::component::ComponentType)]
435             #[derive(wasmtime::component::Lift)]
436             #[derive(wasmtime::component::Lower)]
437             #[component(record)]
438             pub struct NestedBorrow {
439                 #[component(name = "nested-bar")]
440                 pub nested_bar: wasmtime::component::Resource<Bar>,
441             }
442             impl core::fmt::Debug for NestedBorrow {
fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result443                 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
444                     f.debug_struct("NestedBorrow")
445                         .field("nested-bar", &self.nested_bar)
446                         .finish()
447                 }
448             }
449             const _: () = {
450                 assert!(
451                     4 == < NestedBorrow as wasmtime::component::ComponentType >::SIZE32
452                 );
453                 assert!(
454                     4 == < NestedBorrow as wasmtime::component::ComponentType >::ALIGN32
455                 );
456             };
457             pub type SomeHandle = wasmtime::component::Resource<Bar>;
458             const _: () = {
459                 assert!(
460                     4 == < SomeHandle as wasmtime::component::ComponentType >::SIZE32
461                 );
462                 assert!(
463                     4 == < SomeHandle as wasmtime::component::ComponentType >::ALIGN32
464                 );
465             };
466             pub enum Fallible {}
467             pub trait HostFallibleWithStore: wasmtime::component::HasData + Send {
drop<T>( accessor: &wasmtime::component::Accessor<T, Self>, rep: wasmtime::component::Resource<Fallible>, ) -> impl ::core::future::Future<Output = wasmtime::Result<()>> + Send where Self: Sized468                 fn drop<T>(
469                     accessor: &wasmtime::component::Accessor<T, Self>,
470                     rep: wasmtime::component::Resource<Fallible>,
471                 ) -> impl ::core::future::Future<Output = wasmtime::Result<()>> + Send
472                 where
473                     Self: Sized;
new<T: Send>( accessor: &wasmtime::component::Accessor<T, Self>, ) -> impl ::core::future::Future< Output = Result< wasmtime::component::Resource<Fallible>, wasmtime::component::__internal::String, >, > + Send474                 fn new<T: Send>(
475                     accessor: &wasmtime::component::Accessor<T, Self>,
476                 ) -> impl ::core::future::Future<
477                     Output = Result<
478                         wasmtime::component::Resource<Fallible>,
479                         wasmtime::component::__internal::String,
480                     >,
481                 > + Send;
482             }
483             pub trait HostFallible: Send {}
484             impl<_T: HostFallible + ?Sized + Send> HostFallible for &mut _T {}
485             pub trait HostWithStore: wasmtime::component::HasData + HostBarWithStore + HostFallibleWithStore + Send {
bar_own_arg<T: Send>( accessor: &wasmtime::component::Accessor<T, Self>, x: wasmtime::component::Resource<Bar>, ) -> impl ::core::future::Future<Output = ()> + Send486                 fn bar_own_arg<T: Send>(
487                     accessor: &wasmtime::component::Accessor<T, Self>,
488                     x: wasmtime::component::Resource<Bar>,
489                 ) -> impl ::core::future::Future<Output = ()> + Send;
bar_borrow_arg<T: Send>( accessor: &wasmtime::component::Accessor<T, Self>, x: wasmtime::component::Resource<Bar>, ) -> impl ::core::future::Future<Output = ()> + Send490                 fn bar_borrow_arg<T: Send>(
491                     accessor: &wasmtime::component::Accessor<T, Self>,
492                     x: wasmtime::component::Resource<Bar>,
493                 ) -> impl ::core::future::Future<Output = ()> + Send;
bar_result<T: Send>( accessor: &wasmtime::component::Accessor<T, Self>, ) -> impl ::core::future::Future< Output = wasmtime::component::Resource<Bar>, > + Send494                 fn bar_result<T: Send>(
495                     accessor: &wasmtime::component::Accessor<T, Self>,
496                 ) -> impl ::core::future::Future<
497                     Output = wasmtime::component::Resource<Bar>,
498                 > + Send;
tuple_own_arg<T: Send>( accessor: &wasmtime::component::Accessor<T, Self>, x: (wasmtime::component::Resource<Bar>, u32), ) -> impl ::core::future::Future<Output = ()> + Send499                 fn tuple_own_arg<T: Send>(
500                     accessor: &wasmtime::component::Accessor<T, Self>,
501                     x: (wasmtime::component::Resource<Bar>, u32),
502                 ) -> impl ::core::future::Future<Output = ()> + Send;
tuple_borrow_arg<T: Send>( accessor: &wasmtime::component::Accessor<T, Self>, x: (wasmtime::component::Resource<Bar>, u32), ) -> impl ::core::future::Future<Output = ()> + Send503                 fn tuple_borrow_arg<T: Send>(
504                     accessor: &wasmtime::component::Accessor<T, Self>,
505                     x: (wasmtime::component::Resource<Bar>, u32),
506                 ) -> impl ::core::future::Future<Output = ()> + Send;
tuple_result<T: Send>( accessor: &wasmtime::component::Accessor<T, Self>, ) -> impl ::core::future::Future< Output = (wasmtime::component::Resource<Bar>, u32), > + Send507                 fn tuple_result<T: Send>(
508                     accessor: &wasmtime::component::Accessor<T, Self>,
509                 ) -> impl ::core::future::Future<
510                     Output = (wasmtime::component::Resource<Bar>, u32),
511                 > + Send;
option_own_arg<T: Send>( accessor: &wasmtime::component::Accessor<T, Self>, x: Option<wasmtime::component::Resource<Bar>>, ) -> impl ::core::future::Future<Output = ()> + Send512                 fn option_own_arg<T: Send>(
513                     accessor: &wasmtime::component::Accessor<T, Self>,
514                     x: Option<wasmtime::component::Resource<Bar>>,
515                 ) -> impl ::core::future::Future<Output = ()> + Send;
option_borrow_arg<T: Send>( accessor: &wasmtime::component::Accessor<T, Self>, x: Option<wasmtime::component::Resource<Bar>>, ) -> impl ::core::future::Future<Output = ()> + Send516                 fn option_borrow_arg<T: Send>(
517                     accessor: &wasmtime::component::Accessor<T, Self>,
518                     x: Option<wasmtime::component::Resource<Bar>>,
519                 ) -> impl ::core::future::Future<Output = ()> + Send;
option_result<T: Send>( accessor: &wasmtime::component::Accessor<T, Self>, ) -> impl ::core::future::Future< Output = Option<wasmtime::component::Resource<Bar>>, > + Send520                 fn option_result<T: Send>(
521                     accessor: &wasmtime::component::Accessor<T, Self>,
522                 ) -> impl ::core::future::Future<
523                     Output = Option<wasmtime::component::Resource<Bar>>,
524                 > + Send;
result_own_arg<T: Send>( accessor: &wasmtime::component::Accessor<T, Self>, x: Result<wasmtime::component::Resource<Bar>, ()>, ) -> impl ::core::future::Future<Output = ()> + Send525                 fn result_own_arg<T: Send>(
526                     accessor: &wasmtime::component::Accessor<T, Self>,
527                     x: Result<wasmtime::component::Resource<Bar>, ()>,
528                 ) -> impl ::core::future::Future<Output = ()> + Send;
result_borrow_arg<T: Send>( accessor: &wasmtime::component::Accessor<T, Self>, x: Result<wasmtime::component::Resource<Bar>, ()>, ) -> impl ::core::future::Future<Output = ()> + Send529                 fn result_borrow_arg<T: Send>(
530                     accessor: &wasmtime::component::Accessor<T, Self>,
531                     x: Result<wasmtime::component::Resource<Bar>, ()>,
532                 ) -> impl ::core::future::Future<Output = ()> + Send;
result_result<T: Send>( accessor: &wasmtime::component::Accessor<T, Self>, ) -> impl ::core::future::Future< Output = Result<wasmtime::component::Resource<Bar>, ()>, > + Send533                 fn result_result<T: Send>(
534                     accessor: &wasmtime::component::Accessor<T, Self>,
535                 ) -> impl ::core::future::Future<
536                     Output = Result<wasmtime::component::Resource<Bar>, ()>,
537                 > + Send;
list_own_arg<T: Send>( accessor: &wasmtime::component::Accessor<T, Self>, x: wasmtime::component::__internal::Vec< wasmtime::component::Resource<Bar>, >, ) -> impl ::core::future::Future<Output = ()> + Send538                 fn list_own_arg<T: Send>(
539                     accessor: &wasmtime::component::Accessor<T, Self>,
540                     x: wasmtime::component::__internal::Vec<
541                         wasmtime::component::Resource<Bar>,
542                     >,
543                 ) -> impl ::core::future::Future<Output = ()> + Send;
list_borrow_arg<T: Send>( accessor: &wasmtime::component::Accessor<T, Self>, x: wasmtime::component::__internal::Vec< wasmtime::component::Resource<Bar>, >, ) -> impl ::core::future::Future<Output = ()> + Send544                 fn list_borrow_arg<T: Send>(
545                     accessor: &wasmtime::component::Accessor<T, Self>,
546                     x: wasmtime::component::__internal::Vec<
547                         wasmtime::component::Resource<Bar>,
548                     >,
549                 ) -> impl ::core::future::Future<Output = ()> + Send;
list_result<T: Send>( accessor: &wasmtime::component::Accessor<T, Self>, ) -> impl ::core::future::Future< Output = wasmtime::component::__internal::Vec< wasmtime::component::Resource<Bar>, >, > + Send550                 fn list_result<T: Send>(
551                     accessor: &wasmtime::component::Accessor<T, Self>,
552                 ) -> impl ::core::future::Future<
553                     Output = wasmtime::component::__internal::Vec<
554                         wasmtime::component::Resource<Bar>,
555                     >,
556                 > + Send;
record_own_arg<T: Send>( accessor: &wasmtime::component::Accessor<T, Self>, x: NestedOwn, ) -> impl ::core::future::Future<Output = ()> + Send557                 fn record_own_arg<T: Send>(
558                     accessor: &wasmtime::component::Accessor<T, Self>,
559                     x: NestedOwn,
560                 ) -> impl ::core::future::Future<Output = ()> + Send;
record_borrow_arg<T: Send>( accessor: &wasmtime::component::Accessor<T, Self>, x: NestedBorrow, ) -> impl ::core::future::Future<Output = ()> + Send561                 fn record_borrow_arg<T: Send>(
562                     accessor: &wasmtime::component::Accessor<T, Self>,
563                     x: NestedBorrow,
564                 ) -> impl ::core::future::Future<Output = ()> + Send;
record_result<T: Send>( accessor: &wasmtime::component::Accessor<T, Self>, ) -> impl ::core::future::Future<Output = NestedOwn> + Send565                 fn record_result<T: Send>(
566                     accessor: &wasmtime::component::Accessor<T, Self>,
567                 ) -> impl ::core::future::Future<Output = NestedOwn> + Send;
func_with_handle_typedef<T: Send>( accessor: &wasmtime::component::Accessor<T, Self>, x: SomeHandle, ) -> impl ::core::future::Future<Output = ()> + Send568                 fn func_with_handle_typedef<T: Send>(
569                     accessor: &wasmtime::component::Accessor<T, Self>,
570                     x: SomeHandle,
571                 ) -> impl ::core::future::Future<Output = ()> + Send;
572             }
573             pub trait Host: HostBar + HostFallible + Send {}
574             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,575             pub fn add_to_linker<T, D>(
576                 linker: &mut wasmtime::component::Linker<T>,
577                 host_getter: fn(&mut T) -> D::Data<'_>,
578             ) -> wasmtime::Result<()>
579             where
580                 D: HostWithStore,
581                 for<'a> D::Data<'a>: Host,
582                 T: 'static + Send,
583             {
584                 let mut inst = linker.instance("foo:foo/resources")?;
585                 inst.resource_concurrent(
586                     "bar",
587                     wasmtime::component::ResourceType::host::<Bar>(),
588                     move |caller: &wasmtime::component::Accessor<T>, rep| {
589                         wasmtime::component::__internal::Box::pin(async move {
590                             let accessor = &caller.with_getter(host_getter);
591                             wasmtime::ToWasmtimeResult::to_wasmtime_result(
592                                 HostBarWithStore::drop(
593                                         accessor,
594                                         wasmtime::component::Resource::new_own(rep),
595                                     )
596                                     .await,
597                             )
598                         })
599                     },
600                 )?;
601                 inst.resource_concurrent(
602                     "fallible",
603                     wasmtime::component::ResourceType::host::<Fallible>(),
604                     move |caller: &wasmtime::component::Accessor<T>, rep| {
605                         wasmtime::component::__internal::Box::pin(async move {
606                             let accessor = &caller.with_getter(host_getter);
607                             wasmtime::ToWasmtimeResult::to_wasmtime_result(
608                                 HostFallibleWithStore::drop(
609                                         accessor,
610                                         wasmtime::component::Resource::new_own(rep),
611                                     )
612                                     .await,
613                             )
614                         })
615                     },
616                 )?;
617                 inst.func_wrap_concurrent(
618                     "[constructor]bar",
619                     move |caller: &wasmtime::component::Accessor<T>, (): ()| {
620                         wasmtime::component::__internal::Box::pin(async move {
621                             let host = &caller.with_getter(host_getter);
622                             let r = <D as HostBarWithStore>::new(host).await;
623                             Ok((r,))
624                         })
625                     },
626                 )?;
627                 inst.func_wrap_concurrent(
628                     "[static]bar.static-a",
629                     move |caller: &wasmtime::component::Accessor<T>, (): ()| {
630                         wasmtime::component::__internal::Box::pin(async move {
631                             let host = &caller.with_getter(host_getter);
632                             let r = <D as HostBarWithStore>::static_a(host).await;
633                             Ok((r,))
634                         })
635                     },
636                 )?;
637                 inst.func_wrap_concurrent(
638                     "[method]bar.method-a",
639                     move |
640                         caller: &wasmtime::component::Accessor<T>,
641                         (arg0,): (wasmtime::component::Resource<Bar>,)|
642                     {
643                         wasmtime::component::__internal::Box::pin(async move {
644                             let host = &caller.with_getter(host_getter);
645                             let r = <D as HostBarWithStore>::method_a(host, arg0).await;
646                             Ok((r,))
647                         })
648                     },
649                 )?;
650                 inst.func_wrap_concurrent(
651                     "bar-own-arg",
652                     move |
653                         caller: &wasmtime::component::Accessor<T>,
654                         (arg0,): (wasmtime::component::Resource<Bar>,)|
655                     {
656                         wasmtime::component::__internal::Box::pin(async move {
657                             let host = &caller.with_getter(host_getter);
658                             let r = <D as HostWithStore>::bar_own_arg(host, arg0).await;
659                             Ok(r)
660                         })
661                     },
662                 )?;
663                 inst.func_wrap_concurrent(
664                     "bar-borrow-arg",
665                     move |
666                         caller: &wasmtime::component::Accessor<T>,
667                         (arg0,): (wasmtime::component::Resource<Bar>,)|
668                     {
669                         wasmtime::component::__internal::Box::pin(async move {
670                             let host = &caller.with_getter(host_getter);
671                             let r = <D as HostWithStore>::bar_borrow_arg(host, arg0)
672                                 .await;
673                             Ok(r)
674                         })
675                     },
676                 )?;
677                 inst.func_wrap_concurrent(
678                     "bar-result",
679                     move |caller: &wasmtime::component::Accessor<T>, (): ()| {
680                         wasmtime::component::__internal::Box::pin(async move {
681                             let host = &caller.with_getter(host_getter);
682                             let r = <D as HostWithStore>::bar_result(host).await;
683                             Ok((r,))
684                         })
685                     },
686                 )?;
687                 inst.func_wrap_concurrent(
688                     "tuple-own-arg",
689                     move |
690                         caller: &wasmtime::component::Accessor<T>,
691                         (arg0,): ((wasmtime::component::Resource<Bar>, u32),)|
692                     {
693                         wasmtime::component::__internal::Box::pin(async move {
694                             let host = &caller.with_getter(host_getter);
695                             let r = <D as HostWithStore>::tuple_own_arg(host, arg0)
696                                 .await;
697                             Ok(r)
698                         })
699                     },
700                 )?;
701                 inst.func_wrap_concurrent(
702                     "tuple-borrow-arg",
703                     move |
704                         caller: &wasmtime::component::Accessor<T>,
705                         (arg0,): ((wasmtime::component::Resource<Bar>, u32),)|
706                     {
707                         wasmtime::component::__internal::Box::pin(async move {
708                             let host = &caller.with_getter(host_getter);
709                             let r = <D as HostWithStore>::tuple_borrow_arg(host, arg0)
710                                 .await;
711                             Ok(r)
712                         })
713                     },
714                 )?;
715                 inst.func_wrap_concurrent(
716                     "tuple-result",
717                     move |caller: &wasmtime::component::Accessor<T>, (): ()| {
718                         wasmtime::component::__internal::Box::pin(async move {
719                             let host = &caller.with_getter(host_getter);
720                             let r = <D as HostWithStore>::tuple_result(host).await;
721                             Ok((r,))
722                         })
723                     },
724                 )?;
725                 inst.func_wrap_concurrent(
726                     "option-own-arg",
727                     move |
728                         caller: &wasmtime::component::Accessor<T>,
729                         (arg0,): (Option<wasmtime::component::Resource<Bar>>,)|
730                     {
731                         wasmtime::component::__internal::Box::pin(async move {
732                             let host = &caller.with_getter(host_getter);
733                             let r = <D as HostWithStore>::option_own_arg(host, arg0)
734                                 .await;
735                             Ok(r)
736                         })
737                     },
738                 )?;
739                 inst.func_wrap_concurrent(
740                     "option-borrow-arg",
741                     move |
742                         caller: &wasmtime::component::Accessor<T>,
743                         (arg0,): (Option<wasmtime::component::Resource<Bar>>,)|
744                     {
745                         wasmtime::component::__internal::Box::pin(async move {
746                             let host = &caller.with_getter(host_getter);
747                             let r = <D as HostWithStore>::option_borrow_arg(host, arg0)
748                                 .await;
749                             Ok(r)
750                         })
751                     },
752                 )?;
753                 inst.func_wrap_concurrent(
754                     "option-result",
755                     move |caller: &wasmtime::component::Accessor<T>, (): ()| {
756                         wasmtime::component::__internal::Box::pin(async move {
757                             let host = &caller.with_getter(host_getter);
758                             let r = <D as HostWithStore>::option_result(host).await;
759                             Ok((r,))
760                         })
761                     },
762                 )?;
763                 inst.func_wrap_concurrent(
764                     "result-own-arg",
765                     move |
766                         caller: &wasmtime::component::Accessor<T>,
767                         (arg0,): (Result<wasmtime::component::Resource<Bar>, ()>,)|
768                     {
769                         wasmtime::component::__internal::Box::pin(async move {
770                             let host = &caller.with_getter(host_getter);
771                             let r = <D as HostWithStore>::result_own_arg(host, arg0)
772                                 .await;
773                             Ok(r)
774                         })
775                     },
776                 )?;
777                 inst.func_wrap_concurrent(
778                     "result-borrow-arg",
779                     move |
780                         caller: &wasmtime::component::Accessor<T>,
781                         (arg0,): (Result<wasmtime::component::Resource<Bar>, ()>,)|
782                     {
783                         wasmtime::component::__internal::Box::pin(async move {
784                             let host = &caller.with_getter(host_getter);
785                             let r = <D as HostWithStore>::result_borrow_arg(host, arg0)
786                                 .await;
787                             Ok(r)
788                         })
789                     },
790                 )?;
791                 inst.func_wrap_concurrent(
792                     "result-result",
793                     move |caller: &wasmtime::component::Accessor<T>, (): ()| {
794                         wasmtime::component::__internal::Box::pin(async move {
795                             let host = &caller.with_getter(host_getter);
796                             let r = <D as HostWithStore>::result_result(host).await;
797                             Ok((r,))
798                         })
799                     },
800                 )?;
801                 inst.func_wrap_concurrent(
802                     "list-own-arg",
803                     move |
804                         caller: &wasmtime::component::Accessor<T>,
805                         (
806                             arg0,
807                         ): (
808                             wasmtime::component::__internal::Vec<
809                                 wasmtime::component::Resource<Bar>,
810                             >,
811                         )|
812                     {
813                         wasmtime::component::__internal::Box::pin(async move {
814                             let host = &caller.with_getter(host_getter);
815                             let r = <D as HostWithStore>::list_own_arg(host, arg0).await;
816                             Ok(r)
817                         })
818                     },
819                 )?;
820                 inst.func_wrap_concurrent(
821                     "list-borrow-arg",
822                     move |
823                         caller: &wasmtime::component::Accessor<T>,
824                         (
825                             arg0,
826                         ): (
827                             wasmtime::component::__internal::Vec<
828                                 wasmtime::component::Resource<Bar>,
829                             >,
830                         )|
831                     {
832                         wasmtime::component::__internal::Box::pin(async move {
833                             let host = &caller.with_getter(host_getter);
834                             let r = <D as HostWithStore>::list_borrow_arg(host, arg0)
835                                 .await;
836                             Ok(r)
837                         })
838                     },
839                 )?;
840                 inst.func_wrap_concurrent(
841                     "list-result",
842                     move |caller: &wasmtime::component::Accessor<T>, (): ()| {
843                         wasmtime::component::__internal::Box::pin(async move {
844                             let host = &caller.with_getter(host_getter);
845                             let r = <D as HostWithStore>::list_result(host).await;
846                             Ok((r,))
847                         })
848                     },
849                 )?;
850                 inst.func_wrap_concurrent(
851                     "record-own-arg",
852                     move |
853                         caller: &wasmtime::component::Accessor<T>,
854                         (arg0,): (NestedOwn,)|
855                     {
856                         wasmtime::component::__internal::Box::pin(async move {
857                             let host = &caller.with_getter(host_getter);
858                             let r = <D as HostWithStore>::record_own_arg(host, arg0)
859                                 .await;
860                             Ok(r)
861                         })
862                     },
863                 )?;
864                 inst.func_wrap_concurrent(
865                     "record-borrow-arg",
866                     move |
867                         caller: &wasmtime::component::Accessor<T>,
868                         (arg0,): (NestedBorrow,)|
869                     {
870                         wasmtime::component::__internal::Box::pin(async move {
871                             let host = &caller.with_getter(host_getter);
872                             let r = <D as HostWithStore>::record_borrow_arg(host, arg0)
873                                 .await;
874                             Ok(r)
875                         })
876                     },
877                 )?;
878                 inst.func_wrap_concurrent(
879                     "record-result",
880                     move |caller: &wasmtime::component::Accessor<T>, (): ()| {
881                         wasmtime::component::__internal::Box::pin(async move {
882                             let host = &caller.with_getter(host_getter);
883                             let r = <D as HostWithStore>::record_result(host).await;
884                             Ok((r,))
885                         })
886                     },
887                 )?;
888                 inst.func_wrap_concurrent(
889                     "func-with-handle-typedef",
890                     move |
891                         caller: &wasmtime::component::Accessor<T>,
892                         (arg0,): (SomeHandle,)|
893                     {
894                         wasmtime::component::__internal::Box::pin(async move {
895                             let host = &caller.with_getter(host_getter);
896                             let r = <D as HostWithStore>::func_with_handle_typedef(
897                                     host,
898                                     arg0,
899                                 )
900                                 .await;
901                             Ok(r)
902                         })
903                     },
904                 )?;
905                 inst.func_wrap_concurrent(
906                     "[constructor]fallible",
907                     move |caller: &wasmtime::component::Accessor<T>, (): ()| {
908                         wasmtime::component::__internal::Box::pin(async move {
909                             let host = &caller.with_getter(host_getter);
910                             let r = <D as HostFallibleWithStore>::new(host).await;
911                             Ok((r,))
912                         })
913                     },
914                 )?;
915                 Ok(())
916             }
917         }
918         #[allow(clippy::all)]
919         pub mod long_use_chain1 {
920             #[allow(unused_imports)]
921             use wasmtime::component::__internal::Box;
922             pub enum A {}
923             pub trait HostAWithStore: wasmtime::component::HasData {
drop<T>( accessor: &wasmtime::component::Accessor<T, Self>, rep: wasmtime::component::Resource<A>, ) -> impl ::core::future::Future<Output = wasmtime::Result<()>> + Send where Self: Sized924                 fn drop<T>(
925                     accessor: &wasmtime::component::Accessor<T, Self>,
926                     rep: wasmtime::component::Resource<A>,
927                 ) -> impl ::core::future::Future<Output = wasmtime::Result<()>> + Send
928                 where
929                     Self: Sized;
930             }
931             pub trait HostA {}
932             impl<_T: HostA + ?Sized + Send> HostA for &mut _T {}
933             pub trait HostWithStore: wasmtime::component::HasData + HostAWithStore + Send {}
934             impl<_T: ?Sized> HostWithStore for _T
935             where
936                 _T: wasmtime::component::HasData + HostAWithStore + Send,
937             {}
938             pub trait Host: HostA + Send {}
939             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,940             pub fn add_to_linker<T, D>(
941                 linker: &mut wasmtime::component::Linker<T>,
942                 host_getter: fn(&mut T) -> D::Data<'_>,
943             ) -> wasmtime::Result<()>
944             where
945                 D: HostWithStore,
946                 for<'a> D::Data<'a>: Host,
947                 T: 'static + Send,
948             {
949                 let mut inst = linker.instance("foo:foo/long-use-chain1")?;
950                 inst.resource_concurrent(
951                     "a",
952                     wasmtime::component::ResourceType::host::<A>(),
953                     move |caller: &wasmtime::component::Accessor<T>, rep| {
954                         wasmtime::component::__internal::Box::pin(async move {
955                             let accessor = &caller.with_getter(host_getter);
956                             wasmtime::ToWasmtimeResult::to_wasmtime_result(
957                                 HostAWithStore::drop(
958                                         accessor,
959                                         wasmtime::component::Resource::new_own(rep),
960                                     )
961                                     .await,
962                             )
963                         })
964                     },
965                 )?;
966                 Ok(())
967             }
968         }
969         #[allow(clippy::all)]
970         pub mod long_use_chain2 {
971             #[allow(unused_imports)]
972             use wasmtime::component::__internal::Box;
973             pub type A = super::super::super::foo::foo::long_use_chain1::A;
974             pub trait HostWithStore: wasmtime::component::HasData {}
975             impl<_T: ?Sized> HostWithStore for _T
976             where
977                 _T: wasmtime::component::HasData,
978             {}
979             pub trait Host {}
980             impl<_T: Host + ?Sized> 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,981             pub fn add_to_linker<T, D>(
982                 linker: &mut wasmtime::component::Linker<T>,
983                 host_getter: fn(&mut T) -> D::Data<'_>,
984             ) -> wasmtime::Result<()>
985             where
986                 D: HostWithStore,
987                 for<'a> D::Data<'a>: Host,
988                 T: 'static,
989             {
990                 let mut inst = linker.instance("foo:foo/long-use-chain2")?;
991                 Ok(())
992             }
993         }
994         #[allow(clippy::all)]
995         pub mod long_use_chain3 {
996             #[allow(unused_imports)]
997             use wasmtime::component::__internal::Box;
998             pub type A = super::super::super::foo::foo::long_use_chain2::A;
999             pub trait HostWithStore: wasmtime::component::HasData {}
1000             impl<_T: ?Sized> HostWithStore for _T
1001             where
1002                 _T: wasmtime::component::HasData,
1003             {}
1004             pub trait Host {}
1005             impl<_T: Host + ?Sized> 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,1006             pub fn add_to_linker<T, D>(
1007                 linker: &mut wasmtime::component::Linker<T>,
1008                 host_getter: fn(&mut T) -> D::Data<'_>,
1009             ) -> wasmtime::Result<()>
1010             where
1011                 D: HostWithStore,
1012                 for<'a> D::Data<'a>: Host,
1013                 T: 'static,
1014             {
1015                 let mut inst = linker.instance("foo:foo/long-use-chain3")?;
1016                 Ok(())
1017             }
1018         }
1019         #[allow(clippy::all)]
1020         pub mod long_use_chain4 {
1021             #[allow(unused_imports)]
1022             use wasmtime::component::__internal::Box;
1023             pub type A = super::super::super::foo::foo::long_use_chain3::A;
1024             pub trait HostWithStore: wasmtime::component::HasData + Send {
foo<T: Send>( accessor: &wasmtime::component::Accessor<T, Self>, ) -> impl ::core::future::Future< Output = wasmtime::component::Resource<A>, > + Send1025                 fn foo<T: Send>(
1026                     accessor: &wasmtime::component::Accessor<T, Self>,
1027                 ) -> impl ::core::future::Future<
1028                     Output = wasmtime::component::Resource<A>,
1029                 > + Send;
1030             }
1031             pub trait Host: Send {}
1032             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,1033             pub fn add_to_linker<T, D>(
1034                 linker: &mut wasmtime::component::Linker<T>,
1035                 host_getter: fn(&mut T) -> D::Data<'_>,
1036             ) -> wasmtime::Result<()>
1037             where
1038                 D: HostWithStore,
1039                 for<'a> D::Data<'a>: Host,
1040                 T: 'static + Send,
1041             {
1042                 let mut inst = linker.instance("foo:foo/long-use-chain4")?;
1043                 inst.func_wrap_concurrent(
1044                     "foo",
1045                     move |caller: &wasmtime::component::Accessor<T>, (): ()| {
1046                         wasmtime::component::__internal::Box::pin(async move {
1047                             let host = &caller.with_getter(host_getter);
1048                             let r = <D as HostWithStore>::foo(host).await;
1049                             Ok((r,))
1050                         })
1051                     },
1052                 )?;
1053                 Ok(())
1054             }
1055         }
1056         #[allow(clippy::all)]
1057         pub mod transitive_interface_with_resource {
1058             #[allow(unused_imports)]
1059             use wasmtime::component::__internal::Box;
1060             pub enum Foo {}
1061             pub trait HostFooWithStore: wasmtime::component::HasData {
drop<T>( accessor: &wasmtime::component::Accessor<T, Self>, rep: wasmtime::component::Resource<Foo>, ) -> impl ::core::future::Future<Output = wasmtime::Result<()>> + Send where Self: Sized1062                 fn drop<T>(
1063                     accessor: &wasmtime::component::Accessor<T, Self>,
1064                     rep: wasmtime::component::Resource<Foo>,
1065                 ) -> impl ::core::future::Future<Output = wasmtime::Result<()>> + Send
1066                 where
1067                     Self: Sized;
1068             }
1069             pub trait HostFoo {}
1070             impl<_T: HostFoo + ?Sized + Send> HostFoo for &mut _T {}
1071             pub trait HostWithStore: wasmtime::component::HasData + HostFooWithStore + Send {}
1072             impl<_T: ?Sized> HostWithStore for _T
1073             where
1074                 _T: wasmtime::component::HasData + HostFooWithStore + Send,
1075             {}
1076             pub trait Host: HostFoo + Send {}
1077             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,1078             pub fn add_to_linker<T, D>(
1079                 linker: &mut wasmtime::component::Linker<T>,
1080                 host_getter: fn(&mut T) -> D::Data<'_>,
1081             ) -> wasmtime::Result<()>
1082             where
1083                 D: HostWithStore,
1084                 for<'a> D::Data<'a>: Host,
1085                 T: 'static + Send,
1086             {
1087                 let mut inst = linker
1088                     .instance("foo:foo/transitive-interface-with-resource")?;
1089                 inst.resource_concurrent(
1090                     "foo",
1091                     wasmtime::component::ResourceType::host::<Foo>(),
1092                     move |caller: &wasmtime::component::Accessor<T>, rep| {
1093                         wasmtime::component::__internal::Box::pin(async move {
1094                             let accessor = &caller.with_getter(host_getter);
1095                             wasmtime::ToWasmtimeResult::to_wasmtime_result(
1096                                 HostFooWithStore::drop(
1097                                         accessor,
1098                                         wasmtime::component::Resource::new_own(rep),
1099                                     )
1100                                     .await,
1101                             )
1102                         })
1103                     },
1104                 )?;
1105                 Ok(())
1106             }
1107         }
1108     }
1109 }
1110 pub mod exports {
1111     pub mod foo {
1112         pub mod foo {
1113             #[allow(clippy::all)]
1114             pub mod uses_resource_transitively {
1115                 #[allow(unused_imports)]
1116                 use wasmtime::component::__internal::Box;
1117                 pub type Foo = super::super::super::super::foo::foo::transitive_interface_with_resource::Foo;
1118                 #[derive(Clone)]
1119                 pub struct Guest {
1120                     handle: wasmtime::component::Func,
1121                 }
1122                 #[derive(Clone)]
1123                 pub struct GuestIndices {
1124                     handle: wasmtime::component::ComponentExportIndex,
1125                 }
1126                 impl GuestIndices {
1127                     /// Constructor for [`GuestIndices`] which takes a
1128                     /// [`Component`](wasmtime::component::Component) as input and can be executed
1129                     /// before instantiation.
1130                     ///
1131                     /// This constructor can be used to front-load string lookups to find exports
1132                     /// within a component.
new<_T>( _instance_pre: &wasmtime::component::InstancePre<_T>, ) -> wasmtime::Result<GuestIndices>1133                     pub fn new<_T>(
1134                         _instance_pre: &wasmtime::component::InstancePre<_T>,
1135                     ) -> wasmtime::Result<GuestIndices> {
1136                         let instance = _instance_pre
1137                             .component()
1138                             .get_export_index(None, "foo:foo/uses-resource-transitively")
1139                             .ok_or_else(|| {
1140                                 wasmtime::format_err!(
1141                                     "no exported instance named `foo:foo/uses-resource-transitively`"
1142                                 )
1143                             })?;
1144                         let mut lookup = move |name| {
1145                             _instance_pre
1146                                 .component()
1147                                 .get_export_index(Some(&instance), name)
1148                                 .ok_or_else(|| {
1149                                     wasmtime::format_err!(
1150                                         "instance export `foo:foo/uses-resource-transitively` does \
1151                     not have export `{name}`"
1152                                     )
1153                                 })
1154                         };
1155                         let _ = &mut lookup;
1156                         let handle = lookup("handle")?;
1157                         Ok(GuestIndices { handle })
1158                     }
load( &self, mut store: impl wasmtime::AsContextMut, instance: &wasmtime::component::Instance, ) -> wasmtime::Result<Guest>1159                     pub fn load(
1160                         &self,
1161                         mut store: impl wasmtime::AsContextMut,
1162                         instance: &wasmtime::component::Instance,
1163                     ) -> wasmtime::Result<Guest> {
1164                         let _instance = instance;
1165                         let _instance_pre = _instance.instance_pre(&store);
1166                         let _instance_type = _instance_pre.instance_type();
1167                         let mut store = store.as_context_mut();
1168                         let _ = &mut store;
1169                         let handle = *_instance
1170                             .get_typed_func::<
1171                                 (wasmtime::component::Resource<Foo>,),
1172                                 (),
1173                             >(&mut store, &self.handle)?
1174                             .func();
1175                         Ok(Guest { handle })
1176                     }
1177                 }
1178                 impl Guest {
call_handle<_T, _D>( &self, accessor: &wasmtime::component::Accessor<_T, _D>, arg0: wasmtime::component::Resource<Foo>, ) -> wasmtime::Result<()> where _T: Send, _D: wasmtime::component::HasData,1179                     pub async fn call_handle<_T, _D>(
1180                         &self,
1181                         accessor: &wasmtime::component::Accessor<_T, _D>,
1182                         arg0: wasmtime::component::Resource<Foo>,
1183                     ) -> wasmtime::Result<()>
1184                     where
1185                         _T: Send,
1186                         _D: wasmtime::component::HasData,
1187                     {
1188                         let callee = unsafe {
1189                             wasmtime::component::TypedFunc::<
1190                                 (wasmtime::component::Resource<Foo>,),
1191                                 (),
1192                             >::new_unchecked(self.handle)
1193                         };
1194                         let () = callee.call_concurrent(accessor, (arg0,)).await?;
1195                         Ok(())
1196                     }
1197                 }
1198             }
1199         }
1200     }
1201 }
1202