1 pub enum WorldResource {}
2 pub trait HostWorldResourceWithStore: wasmtime::component::HasData + Send {}
3 impl<_T: ?Sized> HostWorldResourceWithStore for _T
4 where
5     _T: wasmtime::component::HasData + Send,
6 {}
7 pub trait HostWorldResource: Send {
new( &mut self, ) -> impl ::core::future::Future< Output = wasmtime::component::Resource<WorldResource>, > + Send8     fn new(
9         &mut self,
10     ) -> impl ::core::future::Future<
11         Output = wasmtime::component::Resource<WorldResource>,
12     > + Send;
foo( &mut self, self_: wasmtime::component::Resource<WorldResource>, ) -> impl ::core::future::Future<Output = ()> + Send13     fn foo(
14         &mut self,
15         self_: wasmtime::component::Resource<WorldResource>,
16     ) -> impl ::core::future::Future<Output = ()> + Send;
static_foo(&mut self) -> impl ::core::future::Future<Output = ()> + Send17     fn static_foo(&mut self) -> impl ::core::future::Future<Output = ()> + Send;
drop( &mut self, rep: wasmtime::component::Resource<WorldResource>, ) -> impl ::core::future::Future<Output = wasmtime::Result<()>> + Send18     fn drop(
19         &mut self,
20         rep: wasmtime::component::Resource<WorldResource>,
21     ) -> impl ::core::future::Future<Output = wasmtime::Result<()>> + Send;
22 }
23 impl<_T: HostWorldResource + ?Sized + Send> HostWorldResource for &mut _T {
new( &mut self, ) -> impl ::core::future::Future< Output = wasmtime::component::Resource<WorldResource>, > + Send24     fn new(
25         &mut self,
26     ) -> impl ::core::future::Future<
27         Output = wasmtime::component::Resource<WorldResource>,
28     > + Send {
29         async move { HostWorldResource::new(*self).await }
30     }
foo( &mut self, self_: wasmtime::component::Resource<WorldResource>, ) -> impl ::core::future::Future<Output = ()> + Send31     fn foo(
32         &mut self,
33         self_: wasmtime::component::Resource<WorldResource>,
34     ) -> impl ::core::future::Future<Output = ()> + Send {
35         async move { HostWorldResource::foo(*self, self_).await }
36     }
static_foo(&mut self) -> impl ::core::future::Future<Output = ()> + Send37     fn static_foo(&mut self) -> impl ::core::future::Future<Output = ()> + Send {
38         async move { HostWorldResource::static_foo(*self).await }
39     }
drop( &mut self, rep: wasmtime::component::Resource<WorldResource>, ) -> wasmtime::Result<()>40     async fn drop(
41         &mut self,
42         rep: wasmtime::component::Resource<WorldResource>,
43     ) -> wasmtime::Result<()> {
44         HostWorldResource::drop(*self, rep).await
45     }
46 }
47 /// Auto-generated bindings for a pre-instantiated version of a
48 /// component which implements the world `the-world`.
49 ///
50 /// This structure is created through [`TheWorldPre::new`] which
51 /// takes a [`InstancePre`](wasmtime::component::InstancePre) that
52 /// has been created through a [`Linker`](wasmtime::component::Linker).
53 ///
54 /// For more information see [`TheWorld`] as well.
55 pub struct TheWorldPre<T: 'static> {
56     instance_pre: wasmtime::component::InstancePre<T>,
57     indices: TheWorldIndices,
58 }
59 impl<T: 'static> Clone for TheWorldPre<T> {
clone(&self) -> Self60     fn clone(&self) -> Self {
61         Self {
62             instance_pre: self.instance_pre.clone(),
63             indices: self.indices.clone(),
64         }
65     }
66 }
67 impl<_T: 'static> TheWorldPre<_T> {
68     /// Creates a new copy of `TheWorldPre` bindings which can then
69     /// be used to instantiate into a particular store.
70     ///
71     /// This method may fail if the component behind `instance_pre`
72     /// does not have the required exports.
new( instance_pre: wasmtime::component::InstancePre<_T>, ) -> wasmtime::Result<Self>73     pub fn new(
74         instance_pre: wasmtime::component::InstancePre<_T>,
75     ) -> wasmtime::Result<Self> {
76         let indices = TheWorldIndices::new(&instance_pre)?;
77         Ok(Self { instance_pre, indices })
78     }
engine(&self) -> &wasmtime::Engine79     pub fn engine(&self) -> &wasmtime::Engine {
80         self.instance_pre.engine()
81     }
instance_pre(&self) -> &wasmtime::component::InstancePre<_T>82     pub fn instance_pre(&self) -> &wasmtime::component::InstancePre<_T> {
83         &self.instance_pre
84     }
85     /// Instantiates a new instance of [`TheWorld`] within the
86     /// `store` provided.
87     ///
88     /// This function will use `self` as the pre-instantiated
89     /// instance to perform instantiation. Afterwards the preloaded
90     /// indices in `self` are used to lookup all exports on the
91     /// resulting instance.
instantiate( &self, mut store: impl wasmtime::AsContextMut<Data = _T>, ) -> wasmtime::Result<TheWorld>92     pub fn instantiate(
93         &self,
94         mut store: impl wasmtime::AsContextMut<Data = _T>,
95     ) -> wasmtime::Result<TheWorld> {
96         let mut store = store.as_context_mut();
97         let instance = self.instance_pre.instantiate(&mut store)?;
98         self.indices.load(&mut store, &instance)
99     }
100 }
101 impl<_T: Send + 'static> TheWorldPre<_T> {
102     /// Same as [`Self::instantiate`], except with `async`.
instantiate_async( &self, mut store: impl wasmtime::AsContextMut<Data = _T>, ) -> wasmtime::Result<TheWorld>103     pub async fn instantiate_async(
104         &self,
105         mut store: impl wasmtime::AsContextMut<Data = _T>,
106     ) -> wasmtime::Result<TheWorld> {
107         let mut store = store.as_context_mut();
108         let instance = self.instance_pre.instantiate_async(&mut store).await?;
109         self.indices.load(&mut store, &instance)
110     }
111 }
112 /// Auto-generated bindings for index of the exports of
113 /// `the-world`.
114 ///
115 /// This is an implementation detail of [`TheWorldPre`] and can
116 /// be constructed if needed as well.
117 ///
118 /// For more information see [`TheWorld`] as well.
119 #[derive(Clone)]
120 pub struct TheWorldIndices {
121     interface1: exports::foo::foo::uses_resource_transitively::GuestIndices,
122     some_world_func2: wasmtime::component::ComponentExportIndex,
123 }
124 /// Auto-generated bindings for an instance a component which
125 /// implements the world `the-world`.
126 ///
127 /// This structure can be created through a number of means
128 /// depending on your requirements and what you have on hand:
129 ///
130 /// * The most convenient way is to use
131 ///   [`TheWorld::instantiate`] which only needs a
132 ///   [`Store`], [`Component`], and [`Linker`].
133 ///
134 /// * Alternatively you can create a [`TheWorldPre`] ahead of
135 ///   time with a [`Component`] to front-load string lookups
136 ///   of exports once instead of per-instantiation. This
137 ///   method then uses [`TheWorldPre::instantiate`] to
138 ///   create a [`TheWorld`].
139 ///
140 /// * If you've instantiated the instance yourself already
141 ///   then you can use [`TheWorld::new`].
142 ///
143 /// These methods are all equivalent to one another and move
144 /// around the tradeoff of what work is performed when.
145 ///
146 /// [`Store`]: wasmtime::Store
147 /// [`Component`]: wasmtime::component::Component
148 /// [`Linker`]: wasmtime::component::Linker
149 pub struct TheWorld {
150     interface1: exports::foo::foo::uses_resource_transitively::Guest,
151     some_world_func2: wasmtime::component::Func,
152 }
153 pub trait TheWorldImportsWithStore: wasmtime::component::HasData + HostWorldResourceWithStore + Send {}
154 impl<_T: ?Sized> TheWorldImportsWithStore for _T
155 where
156     _T: wasmtime::component::HasData + HostWorldResourceWithStore + Send,
157 {}
158 pub trait TheWorldImports: HostWorldResource + Send {
some_world_func( &mut self, ) -> impl ::core::future::Future< Output = wasmtime::component::Resource<WorldResource>, > + Send159     fn some_world_func(
160         &mut self,
161     ) -> impl ::core::future::Future<
162         Output = wasmtime::component::Resource<WorldResource>,
163     > + Send;
164 }
165 impl<_T: TheWorldImports + ?Sized + Send> TheWorldImports for &mut _T {
some_world_func( &mut self, ) -> impl ::core::future::Future< Output = wasmtime::component::Resource<WorldResource>, > + Send166     fn some_world_func(
167         &mut self,
168     ) -> impl ::core::future::Future<
169         Output = wasmtime::component::Resource<WorldResource>,
170     > + Send {
171         async move { TheWorldImports::some_world_func(*self).await }
172     }
173 }
174 const _: () = {
175     impl TheWorldIndices {
176         /// Creates a new copy of `TheWorldIndices` bindings which can then
177         /// be used to instantiate into a particular store.
178         ///
179         /// This method may fail if the component does not have the
180         /// required exports.
new<_T>( _instance_pre: &wasmtime::component::InstancePre<_T>, ) -> wasmtime::Result<Self>181         pub fn new<_T>(
182             _instance_pre: &wasmtime::component::InstancePre<_T>,
183         ) -> wasmtime::Result<Self> {
184             let _component = _instance_pre.component();
185             let _instance_type = _instance_pre.instance_type();
186             let interface1 = exports::foo::foo::uses_resource_transitively::GuestIndices::new(
187                 _instance_pre,
188             )?;
189             let some_world_func2 = {
190                 let (item, index) = _component
191                     .get_export(None, "some-world-func2")
192                     .ok_or_else(|| {
193                         wasmtime::format_err!("no export `some-world-func2` found")
194                     })?;
195                 match item {
196                     wasmtime::component::types::ComponentItem::ComponentFunc(func) => {
197                         wasmtime::error::Context::context(
198                             func
199                                 .typecheck::<
200                                     (),
201                                     (wasmtime::component::Resource<WorldResource>,),
202                                 >(&_instance_type),
203                             "type-checking export func `some-world-func2`",
204                         )?;
205                         index
206                     }
207                     _ => {
208                         Err(
209                             wasmtime::format_err!(
210                                 "export `some-world-func2` is not a function"
211                             ),
212                         )?
213                     }
214                 }
215             };
216             Ok(TheWorldIndices {
217                 interface1,
218                 some_world_func2,
219             })
220         }
221         /// Uses the indices stored in `self` to load an instance
222         /// of [`TheWorld`] from the instance provided.
223         ///
224         /// Note that at this time this method will additionally
225         /// perform type-checks of all exports.
load( &self, mut store: impl wasmtime::AsContextMut, instance: &wasmtime::component::Instance, ) -> wasmtime::Result<TheWorld>226         pub fn load(
227             &self,
228             mut store: impl wasmtime::AsContextMut,
229             instance: &wasmtime::component::Instance,
230         ) -> wasmtime::Result<TheWorld> {
231             let _ = &mut store;
232             let _instance = instance;
233             let interface1 = self.interface1.load(&mut store, &_instance)?;
234             let some_world_func2 = *_instance
235                 .get_typed_func::<
236                     (),
237                     (wasmtime::component::Resource<WorldResource>,),
238                 >(&mut store, &self.some_world_func2)?
239                 .func();
240             Ok(TheWorld {
241                 interface1,
242                 some_world_func2,
243             })
244         }
245     }
246     impl TheWorld {
247         /// Convenience wrapper around [`TheWorldPre::new`] and
248         /// [`TheWorldPre::instantiate`].
instantiate<_T>( store: impl wasmtime::AsContextMut<Data = _T>, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, ) -> wasmtime::Result<TheWorld>249         pub fn instantiate<_T>(
250             store: impl wasmtime::AsContextMut<Data = _T>,
251             component: &wasmtime::component::Component,
252             linker: &wasmtime::component::Linker<_T>,
253         ) -> wasmtime::Result<TheWorld> {
254             let pre = linker.instantiate_pre(component)?;
255             TheWorldPre::new(pre)?.instantiate(store)
256         }
257         /// Convenience wrapper around [`TheWorldIndices::new`] and
258         /// [`TheWorldIndices::load`].
new( mut store: impl wasmtime::AsContextMut, instance: &wasmtime::component::Instance, ) -> wasmtime::Result<TheWorld>259         pub fn new(
260             mut store: impl wasmtime::AsContextMut,
261             instance: &wasmtime::component::Instance,
262         ) -> wasmtime::Result<TheWorld> {
263             let indices = TheWorldIndices::new(&instance.instance_pre(&store))?;
264             indices.load(&mut store, instance)
265         }
266         /// Convenience wrapper around [`TheWorldPre::new`] and
267         /// [`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,268         pub async fn instantiate_async<_T>(
269             store: impl wasmtime::AsContextMut<Data = _T>,
270             component: &wasmtime::component::Component,
271             linker: &wasmtime::component::Linker<_T>,
272         ) -> wasmtime::Result<TheWorld>
273         where
274             _T: Send,
275         {
276             let pre = linker.instantiate_pre(component)?;
277             TheWorldPre::new(pre)?.instantiate_async(store).await
278         }
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,279         pub fn add_to_linker_imports<T, D>(
280             linker: &mut wasmtime::component::Linker<T>,
281             host_getter: fn(&mut T) -> D::Data<'_>,
282         ) -> wasmtime::Result<()>
283         where
284             D: TheWorldImportsWithStore,
285             for<'a> D::Data<'a>: TheWorldImports,
286             T: 'static + Send,
287         {
288             let mut linker = linker.root();
289             linker
290                 .resource_async(
291                     "world-resource",
292                     wasmtime::component::ResourceType::host::<WorldResource>(),
293                     move |mut store, rep| {
294                         wasmtime::component::__internal::Box::new(async move {
295                             wasmtime::ToWasmtimeResult::to_wasmtime_result(
296                                 HostWorldResource::drop(
297                                         &mut host_getter(store.data_mut()),
298                                         wasmtime::component::Resource::new_own(rep),
299                                     )
300                                     .await,
301                             )
302                         })
303                     },
304                 )?;
305             linker
306                 .func_wrap_async(
307                     "some-world-func",
308                     move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
309                         use tracing::Instrument;
310                         let span = tracing::span!(
311                             tracing::Level::TRACE, "wit-bindgen import", module =
312                             "the-world", function = "some-world-func",
313                         );
314                         wasmtime::component::__internal::Box::new(
315                             async move {
316                                 tracing::event!(tracing::Level::TRACE, "call");
317                                 let host = &mut host_getter(caller.data_mut());
318                                 let r = TheWorldImports::some_world_func(host).await;
319                                 tracing::event!(
320                                     tracing::Level::TRACE, result = tracing::field::debug(& r),
321                                     "return"
322                                 );
323                                 Ok((r,))
324                             }
325                                 .instrument(span),
326                         )
327                     },
328                 )?;
329             linker
330                 .func_wrap_async(
331                     "[constructor]world-resource",
332                     move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
333                         use tracing::Instrument;
334                         let span = tracing::span!(
335                             tracing::Level::TRACE, "wit-bindgen import", module =
336                             "the-world", function = "[constructor]world-resource",
337                         );
338                         wasmtime::component::__internal::Box::new(
339                             async move {
340                                 tracing::event!(tracing::Level::TRACE, "call");
341                                 let host = &mut host_getter(caller.data_mut());
342                                 let r = HostWorldResource::new(host).await;
343                                 tracing::event!(
344                                     tracing::Level::TRACE, result = tracing::field::debug(& r),
345                                     "return"
346                                 );
347                                 Ok((r,))
348                             }
349                                 .instrument(span),
350                         )
351                     },
352                 )?;
353             linker
354                 .func_wrap_async(
355                     "[method]world-resource.foo",
356                     move |
357                         mut caller: wasmtime::StoreContextMut<'_, T>,
358                         (arg0,): (wasmtime::component::Resource<WorldResource>,)|
359                     {
360                         use tracing::Instrument;
361                         let span = tracing::span!(
362                             tracing::Level::TRACE, "wit-bindgen import", module =
363                             "the-world", function = "[method]world-resource.foo",
364                         );
365                         wasmtime::component::__internal::Box::new(
366                             async move {
367                                 tracing::event!(
368                                     tracing::Level::TRACE, self_ = tracing::field::debug(&
369                                     arg0), "call"
370                                 );
371                                 let host = &mut host_getter(caller.data_mut());
372                                 let r = HostWorldResource::foo(host, arg0).await;
373                                 tracing::event!(
374                                     tracing::Level::TRACE, result = tracing::field::debug(& r),
375                                     "return"
376                                 );
377                                 Ok(r)
378                             }
379                                 .instrument(span),
380                         )
381                     },
382                 )?;
383             linker
384                 .func_wrap_async(
385                     "[static]world-resource.static-foo",
386                     move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
387                         use tracing::Instrument;
388                         let span = tracing::span!(
389                             tracing::Level::TRACE, "wit-bindgen import", module =
390                             "the-world", function = "[static]world-resource.static-foo",
391                         );
392                         wasmtime::component::__internal::Box::new(
393                             async move {
394                                 tracing::event!(tracing::Level::TRACE, "call");
395                                 let host = &mut host_getter(caller.data_mut());
396                                 let r = HostWorldResource::static_foo(host).await;
397                                 tracing::event!(
398                                     tracing::Level::TRACE, result = tracing::field::debug(& r),
399                                     "return"
400                                 );
401                                 Ok(r)
402                             }
403                                 .instrument(span),
404                         )
405                     },
406                 )?;
407             Ok(())
408         }
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,409         pub fn add_to_linker<T, D>(
410             linker: &mut wasmtime::component::Linker<T>,
411             host_getter: fn(&mut T) -> D::Data<'_>,
412         ) -> wasmtime::Result<()>
413         where
414             D: foo::foo::resources::HostWithStore
415                 + foo::foo::long_use_chain1::HostWithStore
416                 + foo::foo::long_use_chain2::HostWithStore
417                 + foo::foo::long_use_chain3::HostWithStore
418                 + foo::foo::long_use_chain4::HostWithStore
419                 + foo::foo::transitive_interface_with_resource::HostWithStore
420                 + TheWorldImportsWithStore + Send,
421             for<'a> D::Data<
422                 'a,
423             >: foo::foo::resources::Host + foo::foo::long_use_chain1::Host
424                 + foo::foo::long_use_chain2::Host + foo::foo::long_use_chain3::Host
425                 + foo::foo::long_use_chain4::Host
426                 + foo::foo::transitive_interface_with_resource::Host + TheWorldImports
427                 + Send,
428             T: 'static + Send,
429         {
430             Self::add_to_linker_imports::<T, D>(linker, host_getter)?;
431             foo::foo::resources::add_to_linker::<T, D>(linker, host_getter)?;
432             foo::foo::long_use_chain1::add_to_linker::<T, D>(linker, host_getter)?;
433             foo::foo::long_use_chain2::add_to_linker::<T, D>(linker, host_getter)?;
434             foo::foo::long_use_chain3::add_to_linker::<T, D>(linker, host_getter)?;
435             foo::foo::long_use_chain4::add_to_linker::<T, D>(linker, host_getter)?;
436             foo::foo::transitive_interface_with_resource::add_to_linker::<
437                 T,
438                 D,
439             >(linker, host_getter)?;
440             Ok(())
441         }
call_some_world_func2<S: wasmtime::AsContextMut>( &self, mut store: S, ) -> wasmtime::Result<wasmtime::component::Resource<WorldResource>> where <S as wasmtime::AsContext>::Data: Send,442         pub async fn call_some_world_func2<S: wasmtime::AsContextMut>(
443             &self,
444             mut store: S,
445         ) -> wasmtime::Result<wasmtime::component::Resource<WorldResource>>
446         where
447             <S as wasmtime::AsContext>::Data: Send,
448         {
449             use tracing::Instrument;
450             let span = tracing::span!(
451                 tracing::Level::TRACE, "wit-bindgen export", module = "default", function
452                 = "some-world-func2",
453             );
454             let callee = unsafe {
455                 wasmtime::component::TypedFunc::<
456                     (),
457                     (wasmtime::component::Resource<WorldResource>,),
458                 >::new_unchecked(self.some_world_func2)
459             };
460             let (ret0,) = callee
461                 .call_async(store.as_context_mut(), ())
462                 .instrument(span.clone())
463                 .await?;
464             Ok(ret0)
465         }
foo_foo_uses_resource_transitively( &self, ) -> &exports::foo::foo::uses_resource_transitively::Guest466         pub fn foo_foo_uses_resource_transitively(
467             &self,
468         ) -> &exports::foo::foo::uses_resource_transitively::Guest {
469             &self.interface1
470         }
471     }
472 };
473 pub mod foo {
474     pub mod foo {
475         #[allow(clippy::all)]
476         pub mod resources {
477             #[allow(unused_imports)]
478             use wasmtime::component::__internal::Box;
479             pub enum Bar {}
480             pub trait HostBarWithStore: wasmtime::component::HasData + Send {}
481             impl<_T: ?Sized> HostBarWithStore for _T
482             where
483                 _T: wasmtime::component::HasData + Send,
484             {}
485             pub trait HostBar: Send {
new( &mut self, ) -> impl ::core::future::Future< Output = wasmtime::component::Resource<Bar>, > + Send486                 fn new(
487                     &mut self,
488                 ) -> impl ::core::future::Future<
489                     Output = wasmtime::component::Resource<Bar>,
490                 > + Send;
static_a( &mut self, ) -> impl ::core::future::Future<Output = u32> + Send491                 fn static_a(
492                     &mut self,
493                 ) -> impl ::core::future::Future<Output = u32> + Send;
method_a( &mut self, self_: wasmtime::component::Resource<Bar>, ) -> impl ::core::future::Future<Output = u32> + Send494                 fn method_a(
495                     &mut self,
496                     self_: wasmtime::component::Resource<Bar>,
497                 ) -> impl ::core::future::Future<Output = u32> + Send;
drop( &mut self, rep: wasmtime::component::Resource<Bar>, ) -> impl ::core::future::Future<Output = wasmtime::Result<()>> + Send498                 fn drop(
499                     &mut self,
500                     rep: wasmtime::component::Resource<Bar>,
501                 ) -> impl ::core::future::Future<Output = wasmtime::Result<()>> + Send;
502             }
503             impl<_T: HostBar + ?Sized + Send> HostBar for &mut _T {
new( &mut self, ) -> impl ::core::future::Future< Output = wasmtime::component::Resource<Bar>, > + Send504                 fn new(
505                     &mut self,
506                 ) -> impl ::core::future::Future<
507                     Output = wasmtime::component::Resource<Bar>,
508                 > + Send {
509                     async move { HostBar::new(*self).await }
510                 }
static_a( &mut self, ) -> impl ::core::future::Future<Output = u32> + Send511                 fn static_a(
512                     &mut self,
513                 ) -> impl ::core::future::Future<Output = u32> + Send {
514                     async move { HostBar::static_a(*self).await }
515                 }
method_a( &mut self, self_: wasmtime::component::Resource<Bar>, ) -> impl ::core::future::Future<Output = u32> + Send516                 fn method_a(
517                     &mut self,
518                     self_: wasmtime::component::Resource<Bar>,
519                 ) -> impl ::core::future::Future<Output = u32> + Send {
520                     async move { HostBar::method_a(*self, self_).await }
521                 }
drop( &mut self, rep: wasmtime::component::Resource<Bar>, ) -> wasmtime::Result<()>522                 async fn drop(
523                     &mut self,
524                     rep: wasmtime::component::Resource<Bar>,
525                 ) -> wasmtime::Result<()> {
526                     HostBar::drop(*self, rep).await
527                 }
528             }
529             #[derive(wasmtime::component::ComponentType)]
530             #[derive(wasmtime::component::Lift)]
531             #[derive(wasmtime::component::Lower)]
532             #[component(record)]
533             pub struct NestedOwn {
534                 #[component(name = "nested-bar")]
535                 pub nested_bar: wasmtime::component::Resource<Bar>,
536             }
537             impl core::fmt::Debug for NestedOwn {
fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result538                 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
539                     f.debug_struct("NestedOwn")
540                         .field("nested-bar", &self.nested_bar)
541                         .finish()
542                 }
543             }
544             const _: () = {
545                 assert!(
546                     4 == < NestedOwn as wasmtime::component::ComponentType >::SIZE32
547                 );
548                 assert!(
549                     4 == < NestedOwn as wasmtime::component::ComponentType >::ALIGN32
550                 );
551             };
552             #[derive(wasmtime::component::ComponentType)]
553             #[derive(wasmtime::component::Lift)]
554             #[derive(wasmtime::component::Lower)]
555             #[component(record)]
556             pub struct NestedBorrow {
557                 #[component(name = "nested-bar")]
558                 pub nested_bar: wasmtime::component::Resource<Bar>,
559             }
560             impl core::fmt::Debug for NestedBorrow {
fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result561                 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
562                     f.debug_struct("NestedBorrow")
563                         .field("nested-bar", &self.nested_bar)
564                         .finish()
565                 }
566             }
567             const _: () = {
568                 assert!(
569                     4 == < NestedBorrow as wasmtime::component::ComponentType >::SIZE32
570                 );
571                 assert!(
572                     4 == < NestedBorrow as wasmtime::component::ComponentType >::ALIGN32
573                 );
574             };
575             pub type SomeHandle = wasmtime::component::Resource<Bar>;
576             const _: () = {
577                 assert!(
578                     4 == < SomeHandle as wasmtime::component::ComponentType >::SIZE32
579                 );
580                 assert!(
581                     4 == < SomeHandle as wasmtime::component::ComponentType >::ALIGN32
582                 );
583             };
584             pub enum Fallible {}
585             pub trait HostFallibleWithStore: wasmtime::component::HasData + Send {}
586             impl<_T: ?Sized> HostFallibleWithStore for _T
587             where
588                 _T: wasmtime::component::HasData + Send,
589             {}
590             pub trait HostFallible: Send {
new( &mut self, ) -> impl ::core::future::Future< Output = Result< wasmtime::component::Resource<Fallible>, wasmtime::component::__internal::String, >, > + Send591                 fn new(
592                     &mut self,
593                 ) -> impl ::core::future::Future<
594                     Output = Result<
595                         wasmtime::component::Resource<Fallible>,
596                         wasmtime::component::__internal::String,
597                     >,
598                 > + Send;
drop( &mut self, rep: wasmtime::component::Resource<Fallible>, ) -> impl ::core::future::Future<Output = wasmtime::Result<()>> + Send599                 fn drop(
600                     &mut self,
601                     rep: wasmtime::component::Resource<Fallible>,
602                 ) -> impl ::core::future::Future<Output = wasmtime::Result<()>> + Send;
603             }
604             impl<_T: HostFallible + ?Sized + Send> HostFallible for &mut _T {
new( &mut self, ) -> impl ::core::future::Future< Output = Result< wasmtime::component::Resource<Fallible>, wasmtime::component::__internal::String, >, > + Send605                 fn new(
606                     &mut self,
607                 ) -> impl ::core::future::Future<
608                     Output = Result<
609                         wasmtime::component::Resource<Fallible>,
610                         wasmtime::component::__internal::String,
611                     >,
612                 > + Send {
613                     async move { HostFallible::new(*self).await }
614                 }
drop( &mut self, rep: wasmtime::component::Resource<Fallible>, ) -> wasmtime::Result<()>615                 async fn drop(
616                     &mut self,
617                     rep: wasmtime::component::Resource<Fallible>,
618                 ) -> wasmtime::Result<()> {
619                     HostFallible::drop(*self, rep).await
620                 }
621             }
622             pub trait HostWithStore: wasmtime::component::HasData + HostBarWithStore + HostFallibleWithStore + Send {}
623             impl<_T: ?Sized> HostWithStore for _T
624             where
625                 _T: wasmtime::component::HasData + HostBarWithStore
626                     + HostFallibleWithStore + Send,
627             {}
628             pub trait Host: HostBar + HostFallible + Send {
bar_own_arg( &mut self, x: wasmtime::component::Resource<Bar>, ) -> impl ::core::future::Future<Output = ()> + Send629                 fn bar_own_arg(
630                     &mut self,
631                     x: wasmtime::component::Resource<Bar>,
632                 ) -> impl ::core::future::Future<Output = ()> + Send;
bar_borrow_arg( &mut self, x: wasmtime::component::Resource<Bar>, ) -> impl ::core::future::Future<Output = ()> + Send633                 fn bar_borrow_arg(
634                     &mut self,
635                     x: wasmtime::component::Resource<Bar>,
636                 ) -> impl ::core::future::Future<Output = ()> + Send;
bar_result( &mut self, ) -> impl ::core::future::Future< Output = wasmtime::component::Resource<Bar>, > + Send637                 fn bar_result(
638                     &mut self,
639                 ) -> impl ::core::future::Future<
640                     Output = wasmtime::component::Resource<Bar>,
641                 > + Send;
tuple_own_arg( &mut self, x: (wasmtime::component::Resource<Bar>, u32), ) -> impl ::core::future::Future<Output = ()> + Send642                 fn tuple_own_arg(
643                     &mut self,
644                     x: (wasmtime::component::Resource<Bar>, u32),
645                 ) -> impl ::core::future::Future<Output = ()> + Send;
tuple_borrow_arg( &mut self, x: (wasmtime::component::Resource<Bar>, u32), ) -> impl ::core::future::Future<Output = ()> + Send646                 fn tuple_borrow_arg(
647                     &mut self,
648                     x: (wasmtime::component::Resource<Bar>, u32),
649                 ) -> impl ::core::future::Future<Output = ()> + Send;
tuple_result( &mut self, ) -> impl ::core::future::Future< Output = (wasmtime::component::Resource<Bar>, u32), > + Send650                 fn tuple_result(
651                     &mut self,
652                 ) -> impl ::core::future::Future<
653                     Output = (wasmtime::component::Resource<Bar>, u32),
654                 > + Send;
option_own_arg( &mut self, x: Option<wasmtime::component::Resource<Bar>>, ) -> impl ::core::future::Future<Output = ()> + Send655                 fn option_own_arg(
656                     &mut self,
657                     x: Option<wasmtime::component::Resource<Bar>>,
658                 ) -> impl ::core::future::Future<Output = ()> + Send;
option_borrow_arg( &mut self, x: Option<wasmtime::component::Resource<Bar>>, ) -> impl ::core::future::Future<Output = ()> + Send659                 fn option_borrow_arg(
660                     &mut self,
661                     x: Option<wasmtime::component::Resource<Bar>>,
662                 ) -> impl ::core::future::Future<Output = ()> + Send;
option_result( &mut self, ) -> impl ::core::future::Future< Output = Option<wasmtime::component::Resource<Bar>>, > + Send663                 fn option_result(
664                     &mut self,
665                 ) -> impl ::core::future::Future<
666                     Output = Option<wasmtime::component::Resource<Bar>>,
667                 > + Send;
result_own_arg( &mut self, x: Result<wasmtime::component::Resource<Bar>, ()>, ) -> impl ::core::future::Future<Output = ()> + Send668                 fn result_own_arg(
669                     &mut self,
670                     x: Result<wasmtime::component::Resource<Bar>, ()>,
671                 ) -> impl ::core::future::Future<Output = ()> + Send;
result_borrow_arg( &mut self, x: Result<wasmtime::component::Resource<Bar>, ()>, ) -> impl ::core::future::Future<Output = ()> + Send672                 fn result_borrow_arg(
673                     &mut self,
674                     x: Result<wasmtime::component::Resource<Bar>, ()>,
675                 ) -> impl ::core::future::Future<Output = ()> + Send;
result_result( &mut self, ) -> impl ::core::future::Future< Output = Result<wasmtime::component::Resource<Bar>, ()>, > + Send676                 fn result_result(
677                     &mut self,
678                 ) -> impl ::core::future::Future<
679                     Output = Result<wasmtime::component::Resource<Bar>, ()>,
680                 > + Send;
list_own_arg( &mut self, x: wasmtime::component::__internal::Vec< wasmtime::component::Resource<Bar>, >, ) -> impl ::core::future::Future<Output = ()> + Send681                 fn list_own_arg(
682                     &mut self,
683                     x: wasmtime::component::__internal::Vec<
684                         wasmtime::component::Resource<Bar>,
685                     >,
686                 ) -> impl ::core::future::Future<Output = ()> + Send;
list_borrow_arg( &mut self, x: wasmtime::component::__internal::Vec< wasmtime::component::Resource<Bar>, >, ) -> impl ::core::future::Future<Output = ()> + Send687                 fn list_borrow_arg(
688                     &mut self,
689                     x: wasmtime::component::__internal::Vec<
690                         wasmtime::component::Resource<Bar>,
691                     >,
692                 ) -> impl ::core::future::Future<Output = ()> + Send;
list_result( &mut self, ) -> impl ::core::future::Future< Output = wasmtime::component::__internal::Vec< wasmtime::component::Resource<Bar>, >, > + Send693                 fn list_result(
694                     &mut self,
695                 ) -> impl ::core::future::Future<
696                     Output = wasmtime::component::__internal::Vec<
697                         wasmtime::component::Resource<Bar>,
698                     >,
699                 > + Send;
record_own_arg( &mut self, x: NestedOwn, ) -> impl ::core::future::Future<Output = ()> + Send700                 fn record_own_arg(
701                     &mut self,
702                     x: NestedOwn,
703                 ) -> impl ::core::future::Future<Output = ()> + Send;
record_borrow_arg( &mut self, x: NestedBorrow, ) -> impl ::core::future::Future<Output = ()> + Send704                 fn record_borrow_arg(
705                     &mut self,
706                     x: NestedBorrow,
707                 ) -> impl ::core::future::Future<Output = ()> + Send;
record_result( &mut self, ) -> impl ::core::future::Future<Output = NestedOwn> + Send708                 fn record_result(
709                     &mut self,
710                 ) -> impl ::core::future::Future<Output = NestedOwn> + Send;
func_with_handle_typedef( &mut self, x: SomeHandle, ) -> impl ::core::future::Future<Output = ()> + Send711                 fn func_with_handle_typedef(
712                     &mut self,
713                     x: SomeHandle,
714                 ) -> impl ::core::future::Future<Output = ()> + Send;
715             }
716             impl<_T: Host + ?Sized + Send> Host for &mut _T {
bar_own_arg( &mut self, x: wasmtime::component::Resource<Bar>, ) -> impl ::core::future::Future<Output = ()> + Send717                 fn bar_own_arg(
718                     &mut self,
719                     x: wasmtime::component::Resource<Bar>,
720                 ) -> impl ::core::future::Future<Output = ()> + Send {
721                     async move { Host::bar_own_arg(*self, x).await }
722                 }
bar_borrow_arg( &mut self, x: wasmtime::component::Resource<Bar>, ) -> impl ::core::future::Future<Output = ()> + Send723                 fn bar_borrow_arg(
724                     &mut self,
725                     x: wasmtime::component::Resource<Bar>,
726                 ) -> impl ::core::future::Future<Output = ()> + Send {
727                     async move { Host::bar_borrow_arg(*self, x).await }
728                 }
bar_result( &mut self, ) -> impl ::core::future::Future< Output = wasmtime::component::Resource<Bar>, > + Send729                 fn bar_result(
730                     &mut self,
731                 ) -> impl ::core::future::Future<
732                     Output = wasmtime::component::Resource<Bar>,
733                 > + Send {
734                     async move { Host::bar_result(*self).await }
735                 }
tuple_own_arg( &mut self, x: (wasmtime::component::Resource<Bar>, u32), ) -> impl ::core::future::Future<Output = ()> + Send736                 fn tuple_own_arg(
737                     &mut self,
738                     x: (wasmtime::component::Resource<Bar>, u32),
739                 ) -> impl ::core::future::Future<Output = ()> + Send {
740                     async move { Host::tuple_own_arg(*self, x).await }
741                 }
tuple_borrow_arg( &mut self, x: (wasmtime::component::Resource<Bar>, u32), ) -> impl ::core::future::Future<Output = ()> + Send742                 fn tuple_borrow_arg(
743                     &mut self,
744                     x: (wasmtime::component::Resource<Bar>, u32),
745                 ) -> impl ::core::future::Future<Output = ()> + Send {
746                     async move { Host::tuple_borrow_arg(*self, x).await }
747                 }
tuple_result( &mut self, ) -> impl ::core::future::Future< Output = (wasmtime::component::Resource<Bar>, u32), > + Send748                 fn tuple_result(
749                     &mut self,
750                 ) -> impl ::core::future::Future<
751                     Output = (wasmtime::component::Resource<Bar>, u32),
752                 > + Send {
753                     async move { Host::tuple_result(*self).await }
754                 }
option_own_arg( &mut self, x: Option<wasmtime::component::Resource<Bar>>, ) -> impl ::core::future::Future<Output = ()> + Send755                 fn option_own_arg(
756                     &mut self,
757                     x: Option<wasmtime::component::Resource<Bar>>,
758                 ) -> impl ::core::future::Future<Output = ()> + Send {
759                     async move { Host::option_own_arg(*self, x).await }
760                 }
option_borrow_arg( &mut self, x: Option<wasmtime::component::Resource<Bar>>, ) -> impl ::core::future::Future<Output = ()> + Send761                 fn option_borrow_arg(
762                     &mut self,
763                     x: Option<wasmtime::component::Resource<Bar>>,
764                 ) -> impl ::core::future::Future<Output = ()> + Send {
765                     async move { Host::option_borrow_arg(*self, x).await }
766                 }
option_result( &mut self, ) -> impl ::core::future::Future< Output = Option<wasmtime::component::Resource<Bar>>, > + Send767                 fn option_result(
768                     &mut self,
769                 ) -> impl ::core::future::Future<
770                     Output = Option<wasmtime::component::Resource<Bar>>,
771                 > + Send {
772                     async move { Host::option_result(*self).await }
773                 }
result_own_arg( &mut self, x: Result<wasmtime::component::Resource<Bar>, ()>, ) -> impl ::core::future::Future<Output = ()> + Send774                 fn result_own_arg(
775                     &mut self,
776                     x: Result<wasmtime::component::Resource<Bar>, ()>,
777                 ) -> impl ::core::future::Future<Output = ()> + Send {
778                     async move { Host::result_own_arg(*self, x).await }
779                 }
result_borrow_arg( &mut self, x: Result<wasmtime::component::Resource<Bar>, ()>, ) -> impl ::core::future::Future<Output = ()> + Send780                 fn result_borrow_arg(
781                     &mut self,
782                     x: Result<wasmtime::component::Resource<Bar>, ()>,
783                 ) -> impl ::core::future::Future<Output = ()> + Send {
784                     async move { Host::result_borrow_arg(*self, x).await }
785                 }
result_result( &mut self, ) -> impl ::core::future::Future< Output = Result<wasmtime::component::Resource<Bar>, ()>, > + Send786                 fn result_result(
787                     &mut self,
788                 ) -> impl ::core::future::Future<
789                     Output = Result<wasmtime::component::Resource<Bar>, ()>,
790                 > + Send {
791                     async move { Host::result_result(*self).await }
792                 }
list_own_arg( &mut self, x: wasmtime::component::__internal::Vec< wasmtime::component::Resource<Bar>, >, ) -> impl ::core::future::Future<Output = ()> + Send793                 fn list_own_arg(
794                     &mut self,
795                     x: wasmtime::component::__internal::Vec<
796                         wasmtime::component::Resource<Bar>,
797                     >,
798                 ) -> impl ::core::future::Future<Output = ()> + Send {
799                     async move { Host::list_own_arg(*self, x).await }
800                 }
list_borrow_arg( &mut self, x: wasmtime::component::__internal::Vec< wasmtime::component::Resource<Bar>, >, ) -> impl ::core::future::Future<Output = ()> + Send801                 fn list_borrow_arg(
802                     &mut self,
803                     x: wasmtime::component::__internal::Vec<
804                         wasmtime::component::Resource<Bar>,
805                     >,
806                 ) -> impl ::core::future::Future<Output = ()> + Send {
807                     async move { Host::list_borrow_arg(*self, x).await }
808                 }
list_result( &mut self, ) -> impl ::core::future::Future< Output = wasmtime::component::__internal::Vec< wasmtime::component::Resource<Bar>, >, > + Send809                 fn list_result(
810                     &mut self,
811                 ) -> impl ::core::future::Future<
812                     Output = wasmtime::component::__internal::Vec<
813                         wasmtime::component::Resource<Bar>,
814                     >,
815                 > + Send {
816                     async move { Host::list_result(*self).await }
817                 }
record_own_arg( &mut self, x: NestedOwn, ) -> impl ::core::future::Future<Output = ()> + Send818                 fn record_own_arg(
819                     &mut self,
820                     x: NestedOwn,
821                 ) -> impl ::core::future::Future<Output = ()> + Send {
822                     async move { Host::record_own_arg(*self, x).await }
823                 }
record_borrow_arg( &mut self, x: NestedBorrow, ) -> impl ::core::future::Future<Output = ()> + Send824                 fn record_borrow_arg(
825                     &mut self,
826                     x: NestedBorrow,
827                 ) -> impl ::core::future::Future<Output = ()> + Send {
828                     async move { Host::record_borrow_arg(*self, x).await }
829                 }
record_result( &mut self, ) -> impl ::core::future::Future<Output = NestedOwn> + Send830                 fn record_result(
831                     &mut self,
832                 ) -> impl ::core::future::Future<Output = NestedOwn> + Send {
833                     async move { Host::record_result(*self).await }
834                 }
func_with_handle_typedef( &mut self, x: SomeHandle, ) -> impl ::core::future::Future<Output = ()> + Send835                 fn func_with_handle_typedef(
836                     &mut self,
837                     x: SomeHandle,
838                 ) -> impl ::core::future::Future<Output = ()> + Send {
839                     async move { Host::func_with_handle_typedef(*self, x).await }
840                 }
841             }
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,842             pub fn add_to_linker<T, D>(
843                 linker: &mut wasmtime::component::Linker<T>,
844                 host_getter: fn(&mut T) -> D::Data<'_>,
845             ) -> wasmtime::Result<()>
846             where
847                 D: HostWithStore,
848                 for<'a> D::Data<'a>: Host,
849                 T: 'static + Send,
850             {
851                 let mut inst = linker.instance("foo:foo/resources")?;
852                 inst.resource_async(
853                     "bar",
854                     wasmtime::component::ResourceType::host::<Bar>(),
855                     move |mut store, rep| {
856                         wasmtime::component::__internal::Box::new(async move {
857                             wasmtime::ToWasmtimeResult::to_wasmtime_result(
858                                 HostBar::drop(
859                                         &mut host_getter(store.data_mut()),
860                                         wasmtime::component::Resource::new_own(rep),
861                                     )
862                                     .await,
863                             )
864                         })
865                     },
866                 )?;
867                 inst.resource_async(
868                     "fallible",
869                     wasmtime::component::ResourceType::host::<Fallible>(),
870                     move |mut store, rep| {
871                         wasmtime::component::__internal::Box::new(async move {
872                             wasmtime::ToWasmtimeResult::to_wasmtime_result(
873                                 HostFallible::drop(
874                                         &mut host_getter(store.data_mut()),
875                                         wasmtime::component::Resource::new_own(rep),
876                                     )
877                                     .await,
878                             )
879                         })
880                     },
881                 )?;
882                 inst.func_wrap_async(
883                     "[constructor]bar",
884                     move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
885                         use tracing::Instrument;
886                         let span = tracing::span!(
887                             tracing::Level::TRACE, "wit-bindgen import", module =
888                             "resources", function = "[constructor]bar",
889                         );
890                         wasmtime::component::__internal::Box::new(
891                             async move {
892                                 tracing::event!(tracing::Level::TRACE, "call");
893                                 let host = &mut host_getter(caller.data_mut());
894                                 let r = HostBar::new(host).await;
895                                 tracing::event!(
896                                     tracing::Level::TRACE, result = tracing::field::debug(& r),
897                                     "return"
898                                 );
899                                 Ok((r,))
900                             }
901                                 .instrument(span),
902                         )
903                     },
904                 )?;
905                 inst.func_wrap_async(
906                     "[static]bar.static-a",
907                     move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
908                         use tracing::Instrument;
909                         let span = tracing::span!(
910                             tracing::Level::TRACE, "wit-bindgen import", module =
911                             "resources", function = "[static]bar.static-a",
912                         );
913                         wasmtime::component::__internal::Box::new(
914                             async move {
915                                 tracing::event!(tracing::Level::TRACE, "call");
916                                 let host = &mut host_getter(caller.data_mut());
917                                 let r = HostBar::static_a(host).await;
918                                 tracing::event!(
919                                     tracing::Level::TRACE, result = tracing::field::debug(& r),
920                                     "return"
921                                 );
922                                 Ok((r,))
923                             }
924                                 .instrument(span),
925                         )
926                     },
927                 )?;
928                 inst.func_wrap_async(
929                     "[method]bar.method-a",
930                     move |
931                         mut caller: wasmtime::StoreContextMut<'_, T>,
932                         (arg0,): (wasmtime::component::Resource<Bar>,)|
933                     {
934                         use tracing::Instrument;
935                         let span = tracing::span!(
936                             tracing::Level::TRACE, "wit-bindgen import", module =
937                             "resources", function = "[method]bar.method-a",
938                         );
939                         wasmtime::component::__internal::Box::new(
940                             async move {
941                                 tracing::event!(
942                                     tracing::Level::TRACE, self_ = tracing::field::debug(&
943                                     arg0), "call"
944                                 );
945                                 let host = &mut host_getter(caller.data_mut());
946                                 let r = HostBar::method_a(host, arg0).await;
947                                 tracing::event!(
948                                     tracing::Level::TRACE, result = tracing::field::debug(& r),
949                                     "return"
950                                 );
951                                 Ok((r,))
952                             }
953                                 .instrument(span),
954                         )
955                     },
956                 )?;
957                 inst.func_wrap_async(
958                     "bar-own-arg",
959                     move |
960                         mut caller: wasmtime::StoreContextMut<'_, T>,
961                         (arg0,): (wasmtime::component::Resource<Bar>,)|
962                     {
963                         use tracing::Instrument;
964                         let span = tracing::span!(
965                             tracing::Level::TRACE, "wit-bindgen import", module =
966                             "resources", function = "bar-own-arg",
967                         );
968                         wasmtime::component::__internal::Box::new(
969                             async move {
970                                 tracing::event!(
971                                     tracing::Level::TRACE, x = tracing::field::debug(& arg0),
972                                     "call"
973                                 );
974                                 let host = &mut host_getter(caller.data_mut());
975                                 let r = Host::bar_own_arg(host, arg0).await;
976                                 tracing::event!(
977                                     tracing::Level::TRACE, result = tracing::field::debug(& r),
978                                     "return"
979                                 );
980                                 Ok(r)
981                             }
982                                 .instrument(span),
983                         )
984                     },
985                 )?;
986                 inst.func_wrap_async(
987                     "bar-borrow-arg",
988                     move |
989                         mut caller: wasmtime::StoreContextMut<'_, T>,
990                         (arg0,): (wasmtime::component::Resource<Bar>,)|
991                     {
992                         use tracing::Instrument;
993                         let span = tracing::span!(
994                             tracing::Level::TRACE, "wit-bindgen import", module =
995                             "resources", function = "bar-borrow-arg",
996                         );
997                         wasmtime::component::__internal::Box::new(
998                             async move {
999                                 tracing::event!(
1000                                     tracing::Level::TRACE, x = tracing::field::debug(& arg0),
1001                                     "call"
1002                                 );
1003                                 let host = &mut host_getter(caller.data_mut());
1004                                 let r = Host::bar_borrow_arg(host, arg0).await;
1005                                 tracing::event!(
1006                                     tracing::Level::TRACE, result = tracing::field::debug(& r),
1007                                     "return"
1008                                 );
1009                                 Ok(r)
1010                             }
1011                                 .instrument(span),
1012                         )
1013                     },
1014                 )?;
1015                 inst.func_wrap_async(
1016                     "bar-result",
1017                     move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
1018                         use tracing::Instrument;
1019                         let span = tracing::span!(
1020                             tracing::Level::TRACE, "wit-bindgen import", module =
1021                             "resources", function = "bar-result",
1022                         );
1023                         wasmtime::component::__internal::Box::new(
1024                             async move {
1025                                 tracing::event!(tracing::Level::TRACE, "call");
1026                                 let host = &mut host_getter(caller.data_mut());
1027                                 let r = Host::bar_result(host).await;
1028                                 tracing::event!(
1029                                     tracing::Level::TRACE, result = tracing::field::debug(& r),
1030                                     "return"
1031                                 );
1032                                 Ok((r,))
1033                             }
1034                                 .instrument(span),
1035                         )
1036                     },
1037                 )?;
1038                 inst.func_wrap_async(
1039                     "tuple-own-arg",
1040                     move |
1041                         mut caller: wasmtime::StoreContextMut<'_, T>,
1042                         (arg0,): ((wasmtime::component::Resource<Bar>, u32),)|
1043                     {
1044                         use tracing::Instrument;
1045                         let span = tracing::span!(
1046                             tracing::Level::TRACE, "wit-bindgen import", module =
1047                             "resources", function = "tuple-own-arg",
1048                         );
1049                         wasmtime::component::__internal::Box::new(
1050                             async move {
1051                                 tracing::event!(
1052                                     tracing::Level::TRACE, x = tracing::field::debug(& arg0),
1053                                     "call"
1054                                 );
1055                                 let host = &mut host_getter(caller.data_mut());
1056                                 let r = Host::tuple_own_arg(host, arg0).await;
1057                                 tracing::event!(
1058                                     tracing::Level::TRACE, result = tracing::field::debug(& r),
1059                                     "return"
1060                                 );
1061                                 Ok(r)
1062                             }
1063                                 .instrument(span),
1064                         )
1065                     },
1066                 )?;
1067                 inst.func_wrap_async(
1068                     "tuple-borrow-arg",
1069                     move |
1070                         mut caller: wasmtime::StoreContextMut<'_, T>,
1071                         (arg0,): ((wasmtime::component::Resource<Bar>, u32),)|
1072                     {
1073                         use tracing::Instrument;
1074                         let span = tracing::span!(
1075                             tracing::Level::TRACE, "wit-bindgen import", module =
1076                             "resources", function = "tuple-borrow-arg",
1077                         );
1078                         wasmtime::component::__internal::Box::new(
1079                             async move {
1080                                 tracing::event!(
1081                                     tracing::Level::TRACE, x = tracing::field::debug(& arg0),
1082                                     "call"
1083                                 );
1084                                 let host = &mut host_getter(caller.data_mut());
1085                                 let r = Host::tuple_borrow_arg(host, arg0).await;
1086                                 tracing::event!(
1087                                     tracing::Level::TRACE, result = tracing::field::debug(& r),
1088                                     "return"
1089                                 );
1090                                 Ok(r)
1091                             }
1092                                 .instrument(span),
1093                         )
1094                     },
1095                 )?;
1096                 inst.func_wrap_async(
1097                     "tuple-result",
1098                     move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
1099                         use tracing::Instrument;
1100                         let span = tracing::span!(
1101                             tracing::Level::TRACE, "wit-bindgen import", module =
1102                             "resources", function = "tuple-result",
1103                         );
1104                         wasmtime::component::__internal::Box::new(
1105                             async move {
1106                                 tracing::event!(tracing::Level::TRACE, "call");
1107                                 let host = &mut host_getter(caller.data_mut());
1108                                 let r = Host::tuple_result(host).await;
1109                                 tracing::event!(
1110                                     tracing::Level::TRACE, result = tracing::field::debug(& r),
1111                                     "return"
1112                                 );
1113                                 Ok((r,))
1114                             }
1115                                 .instrument(span),
1116                         )
1117                     },
1118                 )?;
1119                 inst.func_wrap_async(
1120                     "option-own-arg",
1121                     move |
1122                         mut caller: wasmtime::StoreContextMut<'_, T>,
1123                         (arg0,): (Option<wasmtime::component::Resource<Bar>>,)|
1124                     {
1125                         use tracing::Instrument;
1126                         let span = tracing::span!(
1127                             tracing::Level::TRACE, "wit-bindgen import", module =
1128                             "resources", function = "option-own-arg",
1129                         );
1130                         wasmtime::component::__internal::Box::new(
1131                             async move {
1132                                 tracing::event!(
1133                                     tracing::Level::TRACE, x = tracing::field::debug(& arg0),
1134                                     "call"
1135                                 );
1136                                 let host = &mut host_getter(caller.data_mut());
1137                                 let r = Host::option_own_arg(host, arg0).await;
1138                                 tracing::event!(
1139                                     tracing::Level::TRACE, result = tracing::field::debug(& r),
1140                                     "return"
1141                                 );
1142                                 Ok(r)
1143                             }
1144                                 .instrument(span),
1145                         )
1146                     },
1147                 )?;
1148                 inst.func_wrap_async(
1149                     "option-borrow-arg",
1150                     move |
1151                         mut caller: wasmtime::StoreContextMut<'_, T>,
1152                         (arg0,): (Option<wasmtime::component::Resource<Bar>>,)|
1153                     {
1154                         use tracing::Instrument;
1155                         let span = tracing::span!(
1156                             tracing::Level::TRACE, "wit-bindgen import", module =
1157                             "resources", function = "option-borrow-arg",
1158                         );
1159                         wasmtime::component::__internal::Box::new(
1160                             async move {
1161                                 tracing::event!(
1162                                     tracing::Level::TRACE, x = tracing::field::debug(& arg0),
1163                                     "call"
1164                                 );
1165                                 let host = &mut host_getter(caller.data_mut());
1166                                 let r = Host::option_borrow_arg(host, arg0).await;
1167                                 tracing::event!(
1168                                     tracing::Level::TRACE, result = tracing::field::debug(& r),
1169                                     "return"
1170                                 );
1171                                 Ok(r)
1172                             }
1173                                 .instrument(span),
1174                         )
1175                     },
1176                 )?;
1177                 inst.func_wrap_async(
1178                     "option-result",
1179                     move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
1180                         use tracing::Instrument;
1181                         let span = tracing::span!(
1182                             tracing::Level::TRACE, "wit-bindgen import", module =
1183                             "resources", function = "option-result",
1184                         );
1185                         wasmtime::component::__internal::Box::new(
1186                             async move {
1187                                 tracing::event!(tracing::Level::TRACE, "call");
1188                                 let host = &mut host_getter(caller.data_mut());
1189                                 let r = Host::option_result(host).await;
1190                                 tracing::event!(
1191                                     tracing::Level::TRACE, result = tracing::field::debug(& r),
1192                                     "return"
1193                                 );
1194                                 Ok((r,))
1195                             }
1196                                 .instrument(span),
1197                         )
1198                     },
1199                 )?;
1200                 inst.func_wrap_async(
1201                     "result-own-arg",
1202                     move |
1203                         mut caller: wasmtime::StoreContextMut<'_, T>,
1204                         (arg0,): (Result<wasmtime::component::Resource<Bar>, ()>,)|
1205                     {
1206                         use tracing::Instrument;
1207                         let span = tracing::span!(
1208                             tracing::Level::TRACE, "wit-bindgen import", module =
1209                             "resources", function = "result-own-arg",
1210                         );
1211                         wasmtime::component::__internal::Box::new(
1212                             async move {
1213                                 tracing::event!(
1214                                     tracing::Level::TRACE, x = tracing::field::debug(& arg0),
1215                                     "call"
1216                                 );
1217                                 let host = &mut host_getter(caller.data_mut());
1218                                 let r = Host::result_own_arg(host, arg0).await;
1219                                 tracing::event!(
1220                                     tracing::Level::TRACE, result = tracing::field::debug(& r),
1221                                     "return"
1222                                 );
1223                                 Ok(r)
1224                             }
1225                                 .instrument(span),
1226                         )
1227                     },
1228                 )?;
1229                 inst.func_wrap_async(
1230                     "result-borrow-arg",
1231                     move |
1232                         mut caller: wasmtime::StoreContextMut<'_, T>,
1233                         (arg0,): (Result<wasmtime::component::Resource<Bar>, ()>,)|
1234                     {
1235                         use tracing::Instrument;
1236                         let span = tracing::span!(
1237                             tracing::Level::TRACE, "wit-bindgen import", module =
1238                             "resources", function = "result-borrow-arg",
1239                         );
1240                         wasmtime::component::__internal::Box::new(
1241                             async move {
1242                                 tracing::event!(
1243                                     tracing::Level::TRACE, x = tracing::field::debug(& arg0),
1244                                     "call"
1245                                 );
1246                                 let host = &mut host_getter(caller.data_mut());
1247                                 let r = Host::result_borrow_arg(host, arg0).await;
1248                                 tracing::event!(
1249                                     tracing::Level::TRACE, result = tracing::field::debug(& r),
1250                                     "return"
1251                                 );
1252                                 Ok(r)
1253                             }
1254                                 .instrument(span),
1255                         )
1256                     },
1257                 )?;
1258                 inst.func_wrap_async(
1259                     "result-result",
1260                     move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
1261                         use tracing::Instrument;
1262                         let span = tracing::span!(
1263                             tracing::Level::TRACE, "wit-bindgen import", module =
1264                             "resources", function = "result-result",
1265                         );
1266                         wasmtime::component::__internal::Box::new(
1267                             async move {
1268                                 tracing::event!(tracing::Level::TRACE, "call");
1269                                 let host = &mut host_getter(caller.data_mut());
1270                                 let r = Host::result_result(host).await;
1271                                 tracing::event!(
1272                                     tracing::Level::TRACE, result = tracing::field::debug(& r),
1273                                     "return"
1274                                 );
1275                                 Ok((r,))
1276                             }
1277                                 .instrument(span),
1278                         )
1279                     },
1280                 )?;
1281                 inst.func_wrap_async(
1282                     "list-own-arg",
1283                     move |
1284                         mut caller: wasmtime::StoreContextMut<'_, T>,
1285                         (
1286                             arg0,
1287                         ): (
1288                             wasmtime::component::__internal::Vec<
1289                                 wasmtime::component::Resource<Bar>,
1290                             >,
1291                         )|
1292                     {
1293                         use tracing::Instrument;
1294                         let span = tracing::span!(
1295                             tracing::Level::TRACE, "wit-bindgen import", module =
1296                             "resources", function = "list-own-arg",
1297                         );
1298                         wasmtime::component::__internal::Box::new(
1299                             async move {
1300                                 tracing::event!(
1301                                     tracing::Level::TRACE, x = tracing::field::debug("..."),
1302                                     "call"
1303                                 );
1304                                 let host = &mut host_getter(caller.data_mut());
1305                                 let r = Host::list_own_arg(host, arg0).await;
1306                                 tracing::event!(
1307                                     tracing::Level::TRACE, result = tracing::field::debug(& r),
1308                                     "return"
1309                                 );
1310                                 Ok(r)
1311                             }
1312                                 .instrument(span),
1313                         )
1314                     },
1315                 )?;
1316                 inst.func_wrap_async(
1317                     "list-borrow-arg",
1318                     move |
1319                         mut caller: wasmtime::StoreContextMut<'_, T>,
1320                         (
1321                             arg0,
1322                         ): (
1323                             wasmtime::component::__internal::Vec<
1324                                 wasmtime::component::Resource<Bar>,
1325                             >,
1326                         )|
1327                     {
1328                         use tracing::Instrument;
1329                         let span = tracing::span!(
1330                             tracing::Level::TRACE, "wit-bindgen import", module =
1331                             "resources", function = "list-borrow-arg",
1332                         );
1333                         wasmtime::component::__internal::Box::new(
1334                             async move {
1335                                 tracing::event!(
1336                                     tracing::Level::TRACE, x = tracing::field::debug("..."),
1337                                     "call"
1338                                 );
1339                                 let host = &mut host_getter(caller.data_mut());
1340                                 let r = Host::list_borrow_arg(host, arg0).await;
1341                                 tracing::event!(
1342                                     tracing::Level::TRACE, result = tracing::field::debug(& r),
1343                                     "return"
1344                                 );
1345                                 Ok(r)
1346                             }
1347                                 .instrument(span),
1348                         )
1349                     },
1350                 )?;
1351                 inst.func_wrap_async(
1352                     "list-result",
1353                     move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
1354                         use tracing::Instrument;
1355                         let span = tracing::span!(
1356                             tracing::Level::TRACE, "wit-bindgen import", module =
1357                             "resources", function = "list-result",
1358                         );
1359                         wasmtime::component::__internal::Box::new(
1360                             async move {
1361                                 tracing::event!(tracing::Level::TRACE, "call");
1362                                 let host = &mut host_getter(caller.data_mut());
1363                                 let r = Host::list_result(host).await;
1364                                 tracing::event!(
1365                                     tracing::Level::TRACE, result =
1366                                     tracing::field::debug("..."), "return"
1367                                 );
1368                                 Ok((r,))
1369                             }
1370                                 .instrument(span),
1371                         )
1372                     },
1373                 )?;
1374                 inst.func_wrap_async(
1375                     "record-own-arg",
1376                     move |
1377                         mut caller: wasmtime::StoreContextMut<'_, T>,
1378                         (arg0,): (NestedOwn,)|
1379                     {
1380                         use tracing::Instrument;
1381                         let span = tracing::span!(
1382                             tracing::Level::TRACE, "wit-bindgen import", module =
1383                             "resources", function = "record-own-arg",
1384                         );
1385                         wasmtime::component::__internal::Box::new(
1386                             async move {
1387                                 tracing::event!(
1388                                     tracing::Level::TRACE, x = tracing::field::debug(& arg0),
1389                                     "call"
1390                                 );
1391                                 let host = &mut host_getter(caller.data_mut());
1392                                 let r = Host::record_own_arg(host, arg0).await;
1393                                 tracing::event!(
1394                                     tracing::Level::TRACE, result = tracing::field::debug(& r),
1395                                     "return"
1396                                 );
1397                                 Ok(r)
1398                             }
1399                                 .instrument(span),
1400                         )
1401                     },
1402                 )?;
1403                 inst.func_wrap_async(
1404                     "record-borrow-arg",
1405                     move |
1406                         mut caller: wasmtime::StoreContextMut<'_, T>,
1407                         (arg0,): (NestedBorrow,)|
1408                     {
1409                         use tracing::Instrument;
1410                         let span = tracing::span!(
1411                             tracing::Level::TRACE, "wit-bindgen import", module =
1412                             "resources", function = "record-borrow-arg",
1413                         );
1414                         wasmtime::component::__internal::Box::new(
1415                             async move {
1416                                 tracing::event!(
1417                                     tracing::Level::TRACE, x = tracing::field::debug(& arg0),
1418                                     "call"
1419                                 );
1420                                 let host = &mut host_getter(caller.data_mut());
1421                                 let r = Host::record_borrow_arg(host, arg0).await;
1422                                 tracing::event!(
1423                                     tracing::Level::TRACE, result = tracing::field::debug(& r),
1424                                     "return"
1425                                 );
1426                                 Ok(r)
1427                             }
1428                                 .instrument(span),
1429                         )
1430                     },
1431                 )?;
1432                 inst.func_wrap_async(
1433                     "record-result",
1434                     move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
1435                         use tracing::Instrument;
1436                         let span = tracing::span!(
1437                             tracing::Level::TRACE, "wit-bindgen import", module =
1438                             "resources", function = "record-result",
1439                         );
1440                         wasmtime::component::__internal::Box::new(
1441                             async move {
1442                                 tracing::event!(tracing::Level::TRACE, "call");
1443                                 let host = &mut host_getter(caller.data_mut());
1444                                 let r = Host::record_result(host).await;
1445                                 tracing::event!(
1446                                     tracing::Level::TRACE, result = tracing::field::debug(& r),
1447                                     "return"
1448                                 );
1449                                 Ok((r,))
1450                             }
1451                                 .instrument(span),
1452                         )
1453                     },
1454                 )?;
1455                 inst.func_wrap_async(
1456                     "func-with-handle-typedef",
1457                     move |
1458                         mut caller: wasmtime::StoreContextMut<'_, T>,
1459                         (arg0,): (SomeHandle,)|
1460                     {
1461                         use tracing::Instrument;
1462                         let span = tracing::span!(
1463                             tracing::Level::TRACE, "wit-bindgen import", module =
1464                             "resources", function = "func-with-handle-typedef",
1465                         );
1466                         wasmtime::component::__internal::Box::new(
1467                             async move {
1468                                 tracing::event!(
1469                                     tracing::Level::TRACE, x = tracing::field::debug(& arg0),
1470                                     "call"
1471                                 );
1472                                 let host = &mut host_getter(caller.data_mut());
1473                                 let r = Host::func_with_handle_typedef(host, arg0).await;
1474                                 tracing::event!(
1475                                     tracing::Level::TRACE, result = tracing::field::debug(& r),
1476                                     "return"
1477                                 );
1478                                 Ok(r)
1479                             }
1480                                 .instrument(span),
1481                         )
1482                     },
1483                 )?;
1484                 inst.func_wrap_async(
1485                     "[constructor]fallible",
1486                     move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
1487                         use tracing::Instrument;
1488                         let span = tracing::span!(
1489                             tracing::Level::TRACE, "wit-bindgen import", module =
1490                             "resources", function = "[constructor]fallible",
1491                         );
1492                         wasmtime::component::__internal::Box::new(
1493                             async move {
1494                                 tracing::event!(tracing::Level::TRACE, "call");
1495                                 let host = &mut host_getter(caller.data_mut());
1496                                 let r = HostFallible::new(host).await;
1497                                 tracing::event!(
1498                                     tracing::Level::TRACE, result = tracing::field::debug(& r),
1499                                     "return"
1500                                 );
1501                                 Ok((r,))
1502                             }
1503                                 .instrument(span),
1504                         )
1505                     },
1506                 )?;
1507                 Ok(())
1508             }
1509         }
1510         #[allow(clippy::all)]
1511         pub mod long_use_chain1 {
1512             #[allow(unused_imports)]
1513             use wasmtime::component::__internal::Box;
1514             pub enum A {}
1515             pub trait HostAWithStore: wasmtime::component::HasData {}
1516             impl<_T: ?Sized> HostAWithStore for _T
1517             where
1518                 _T: wasmtime::component::HasData,
1519             {}
1520             pub trait HostA {
drop( &mut self, rep: wasmtime::component::Resource<A>, ) -> impl ::core::future::Future<Output = wasmtime::Result<()>> + Send1521                 fn drop(
1522                     &mut self,
1523                     rep: wasmtime::component::Resource<A>,
1524                 ) -> impl ::core::future::Future<Output = wasmtime::Result<()>> + Send;
1525             }
1526             impl<_T: HostA + ?Sized + Send> HostA for &mut _T {
drop( &mut self, rep: wasmtime::component::Resource<A>, ) -> wasmtime::Result<()>1527                 async fn drop(
1528                     &mut self,
1529                     rep: wasmtime::component::Resource<A>,
1530                 ) -> wasmtime::Result<()> {
1531                     HostA::drop(*self, rep).await
1532                 }
1533             }
1534             pub trait HostWithStore: wasmtime::component::HasData + HostAWithStore + Send {}
1535             impl<_T: ?Sized> HostWithStore for _T
1536             where
1537                 _T: wasmtime::component::HasData + HostAWithStore + Send,
1538             {}
1539             pub trait Host: HostA + Send {}
1540             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,1541             pub fn add_to_linker<T, D>(
1542                 linker: &mut wasmtime::component::Linker<T>,
1543                 host_getter: fn(&mut T) -> D::Data<'_>,
1544             ) -> wasmtime::Result<()>
1545             where
1546                 D: HostWithStore,
1547                 for<'a> D::Data<'a>: Host,
1548                 T: 'static + Send,
1549             {
1550                 let mut inst = linker.instance("foo:foo/long-use-chain1")?;
1551                 inst.resource_async(
1552                     "a",
1553                     wasmtime::component::ResourceType::host::<A>(),
1554                     move |mut store, rep| {
1555                         wasmtime::component::__internal::Box::new(async move {
1556                             wasmtime::ToWasmtimeResult::to_wasmtime_result(
1557                                 HostA::drop(
1558                                         &mut host_getter(store.data_mut()),
1559                                         wasmtime::component::Resource::new_own(rep),
1560                                     )
1561                                     .await,
1562                             )
1563                         })
1564                     },
1565                 )?;
1566                 Ok(())
1567             }
1568         }
1569         #[allow(clippy::all)]
1570         pub mod long_use_chain2 {
1571             #[allow(unused_imports)]
1572             use wasmtime::component::__internal::Box;
1573             pub type A = super::super::super::foo::foo::long_use_chain1::A;
1574             pub trait HostWithStore: wasmtime::component::HasData {}
1575             impl<_T: ?Sized> HostWithStore for _T
1576             where
1577                 _T: wasmtime::component::HasData,
1578             {}
1579             pub trait Host {}
1580             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,1581             pub fn add_to_linker<T, D>(
1582                 linker: &mut wasmtime::component::Linker<T>,
1583                 host_getter: fn(&mut T) -> D::Data<'_>,
1584             ) -> wasmtime::Result<()>
1585             where
1586                 D: HostWithStore,
1587                 for<'a> D::Data<'a>: Host,
1588                 T: 'static,
1589             {
1590                 let mut inst = linker.instance("foo:foo/long-use-chain2")?;
1591                 Ok(())
1592             }
1593         }
1594         #[allow(clippy::all)]
1595         pub mod long_use_chain3 {
1596             #[allow(unused_imports)]
1597             use wasmtime::component::__internal::Box;
1598             pub type A = super::super::super::foo::foo::long_use_chain2::A;
1599             pub trait HostWithStore: wasmtime::component::HasData {}
1600             impl<_T: ?Sized> HostWithStore for _T
1601             where
1602                 _T: wasmtime::component::HasData,
1603             {}
1604             pub trait Host {}
1605             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,1606             pub fn add_to_linker<T, D>(
1607                 linker: &mut wasmtime::component::Linker<T>,
1608                 host_getter: fn(&mut T) -> D::Data<'_>,
1609             ) -> wasmtime::Result<()>
1610             where
1611                 D: HostWithStore,
1612                 for<'a> D::Data<'a>: Host,
1613                 T: 'static,
1614             {
1615                 let mut inst = linker.instance("foo:foo/long-use-chain3")?;
1616                 Ok(())
1617             }
1618         }
1619         #[allow(clippy::all)]
1620         pub mod long_use_chain4 {
1621             #[allow(unused_imports)]
1622             use wasmtime::component::__internal::Box;
1623             pub type A = super::super::super::foo::foo::long_use_chain3::A;
1624             pub trait HostWithStore: wasmtime::component::HasData + Send {}
1625             impl<_T: ?Sized> HostWithStore for _T
1626             where
1627                 _T: wasmtime::component::HasData + Send,
1628             {}
1629             pub trait Host: Send {
foo( &mut self, ) -> impl ::core::future::Future< Output = wasmtime::component::Resource<A>, > + Send1630                 fn foo(
1631                     &mut self,
1632                 ) -> impl ::core::future::Future<
1633                     Output = wasmtime::component::Resource<A>,
1634                 > + Send;
1635             }
1636             impl<_T: Host + ?Sized + Send> Host for &mut _T {
foo( &mut self, ) -> impl ::core::future::Future< Output = wasmtime::component::Resource<A>, > + Send1637                 fn foo(
1638                     &mut self,
1639                 ) -> impl ::core::future::Future<
1640                     Output = wasmtime::component::Resource<A>,
1641                 > + Send {
1642                     async move { Host::foo(*self).await }
1643                 }
1644             }
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,1645             pub fn add_to_linker<T, D>(
1646                 linker: &mut wasmtime::component::Linker<T>,
1647                 host_getter: fn(&mut T) -> D::Data<'_>,
1648             ) -> wasmtime::Result<()>
1649             where
1650                 D: HostWithStore,
1651                 for<'a> D::Data<'a>: Host,
1652                 T: 'static + Send,
1653             {
1654                 let mut inst = linker.instance("foo:foo/long-use-chain4")?;
1655                 inst.func_wrap_async(
1656                     "foo",
1657                     move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
1658                         use tracing::Instrument;
1659                         let span = tracing::span!(
1660                             tracing::Level::TRACE, "wit-bindgen import", module =
1661                             "long-use-chain4", function = "foo",
1662                         );
1663                         wasmtime::component::__internal::Box::new(
1664                             async move {
1665                                 tracing::event!(tracing::Level::TRACE, "call");
1666                                 let host = &mut host_getter(caller.data_mut());
1667                                 let r = Host::foo(host).await;
1668                                 tracing::event!(
1669                                     tracing::Level::TRACE, result = tracing::field::debug(& r),
1670                                     "return"
1671                                 );
1672                                 Ok((r,))
1673                             }
1674                                 .instrument(span),
1675                         )
1676                     },
1677                 )?;
1678                 Ok(())
1679             }
1680         }
1681         #[allow(clippy::all)]
1682         pub mod transitive_interface_with_resource {
1683             #[allow(unused_imports)]
1684             use wasmtime::component::__internal::Box;
1685             pub enum Foo {}
1686             pub trait HostFooWithStore: wasmtime::component::HasData {}
1687             impl<_T: ?Sized> HostFooWithStore for _T
1688             where
1689                 _T: wasmtime::component::HasData,
1690             {}
1691             pub trait HostFoo {
drop( &mut self, rep: wasmtime::component::Resource<Foo>, ) -> impl ::core::future::Future<Output = wasmtime::Result<()>> + Send1692                 fn drop(
1693                     &mut self,
1694                     rep: wasmtime::component::Resource<Foo>,
1695                 ) -> impl ::core::future::Future<Output = wasmtime::Result<()>> + Send;
1696             }
1697             impl<_T: HostFoo + ?Sized + Send> HostFoo for &mut _T {
drop( &mut self, rep: wasmtime::component::Resource<Foo>, ) -> wasmtime::Result<()>1698                 async fn drop(
1699                     &mut self,
1700                     rep: wasmtime::component::Resource<Foo>,
1701                 ) -> wasmtime::Result<()> {
1702                     HostFoo::drop(*self, rep).await
1703                 }
1704             }
1705             pub trait HostWithStore: wasmtime::component::HasData + HostFooWithStore + Send {}
1706             impl<_T: ?Sized> HostWithStore for _T
1707             where
1708                 _T: wasmtime::component::HasData + HostFooWithStore + Send,
1709             {}
1710             pub trait Host: HostFoo + Send {}
1711             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,1712             pub fn add_to_linker<T, D>(
1713                 linker: &mut wasmtime::component::Linker<T>,
1714                 host_getter: fn(&mut T) -> D::Data<'_>,
1715             ) -> wasmtime::Result<()>
1716             where
1717                 D: HostWithStore,
1718                 for<'a> D::Data<'a>: Host,
1719                 T: 'static + Send,
1720             {
1721                 let mut inst = linker
1722                     .instance("foo:foo/transitive-interface-with-resource")?;
1723                 inst.resource_async(
1724                     "foo",
1725                     wasmtime::component::ResourceType::host::<Foo>(),
1726                     move |mut store, rep| {
1727                         wasmtime::component::__internal::Box::new(async move {
1728                             wasmtime::ToWasmtimeResult::to_wasmtime_result(
1729                                 HostFoo::drop(
1730                                         &mut host_getter(store.data_mut()),
1731                                         wasmtime::component::Resource::new_own(rep),
1732                                     )
1733                                     .await,
1734                             )
1735                         })
1736                     },
1737                 )?;
1738                 Ok(())
1739             }
1740         }
1741     }
1742 }
1743 pub mod exports {
1744     pub mod foo {
1745         pub mod foo {
1746             #[allow(clippy::all)]
1747             pub mod uses_resource_transitively {
1748                 #[allow(unused_imports)]
1749                 use wasmtime::component::__internal::Box;
1750                 pub type Foo = super::super::super::super::foo::foo::transitive_interface_with_resource::Foo;
1751                 #[derive(Clone)]
1752                 pub struct Guest {
1753                     handle: wasmtime::component::Func,
1754                 }
1755                 #[derive(Clone)]
1756                 pub struct GuestIndices {
1757                     handle: wasmtime::component::ComponentExportIndex,
1758                 }
1759                 impl GuestIndices {
1760                     /// Constructor for [`GuestIndices`] which takes a
1761                     /// [`Component`](wasmtime::component::Component) as input and can be executed
1762                     /// before instantiation.
1763                     ///
1764                     /// This constructor can be used to front-load string lookups to find exports
1765                     /// within a component.
new<_T>( _instance_pre: &wasmtime::component::InstancePre<_T>, ) -> wasmtime::Result<GuestIndices>1766                     pub fn new<_T>(
1767                         _instance_pre: &wasmtime::component::InstancePre<_T>,
1768                     ) -> wasmtime::Result<GuestIndices> {
1769                         let instance = _instance_pre
1770                             .component()
1771                             .get_export_index(None, "foo:foo/uses-resource-transitively")
1772                             .ok_or_else(|| {
1773                                 wasmtime::format_err!(
1774                                     "no exported instance named `foo:foo/uses-resource-transitively`"
1775                                 )
1776                             })?;
1777                         let mut lookup = move |name| {
1778                             _instance_pre
1779                                 .component()
1780                                 .get_export_index(Some(&instance), name)
1781                                 .ok_or_else(|| {
1782                                     wasmtime::format_err!(
1783                                         "instance export `foo:foo/uses-resource-transitively` does \
1784                                                                                 not have export `{name}`"
1785                                     )
1786                                 })
1787                         };
1788                         let _ = &mut lookup;
1789                         let handle = lookup("handle")?;
1790                         Ok(GuestIndices { handle })
1791                     }
load( &self, mut store: impl wasmtime::AsContextMut, instance: &wasmtime::component::Instance, ) -> wasmtime::Result<Guest>1792                     pub fn load(
1793                         &self,
1794                         mut store: impl wasmtime::AsContextMut,
1795                         instance: &wasmtime::component::Instance,
1796                     ) -> wasmtime::Result<Guest> {
1797                         let _instance = instance;
1798                         let _instance_pre = _instance.instance_pre(&store);
1799                         let _instance_type = _instance_pre.instance_type();
1800                         let mut store = store.as_context_mut();
1801                         let _ = &mut store;
1802                         let handle = *_instance
1803                             .get_typed_func::<
1804                                 (wasmtime::component::Resource<Foo>,),
1805                                 (),
1806                             >(&mut store, &self.handle)?
1807                             .func();
1808                         Ok(Guest { handle })
1809                     }
1810                 }
1811                 impl Guest {
call_handle<S: wasmtime::AsContextMut>( &self, mut store: S, arg0: wasmtime::component::Resource<Foo>, ) -> wasmtime::Result<()> where <S as wasmtime::AsContext>::Data: Send,1812                     pub async fn call_handle<S: wasmtime::AsContextMut>(
1813                         &self,
1814                         mut store: S,
1815                         arg0: wasmtime::component::Resource<Foo>,
1816                     ) -> wasmtime::Result<()>
1817                     where
1818                         <S as wasmtime::AsContext>::Data: Send,
1819                     {
1820                         use tracing::Instrument;
1821                         let span = tracing::span!(
1822                             tracing::Level::TRACE, "wit-bindgen export", module =
1823                             "foo:foo/uses-resource-transitively", function = "handle",
1824                         );
1825                         let callee = unsafe {
1826                             wasmtime::component::TypedFunc::<
1827                                 (wasmtime::component::Resource<Foo>,),
1828                                 (),
1829                             >::new_unchecked(self.handle)
1830                         };
1831                         let () = callee
1832                             .call_async(store.as_context_mut(), (arg0,))
1833                             .instrument(span.clone())
1834                             .await?;
1835                         Ok(())
1836                     }
1837                 }
1838             }
1839         }
1840     }
1841 }
1842