Path: blob/main/crates/component-macro/tests/expanded/integers_tracing_async.rs
3092 views
/// Auto-generated bindings for a pre-instantiated version of a1/// component which implements the world `the-world`.2///3/// This structure is created through [`TheWorldPre::new`] which4/// takes a [`InstancePre`](wasmtime::component::InstancePre) that5/// has been created through a [`Linker`](wasmtime::component::Linker).6///7/// For more information see [`TheWorld`] as well.8pub struct TheWorldPre<T: 'static> {9instance_pre: wasmtime::component::InstancePre<T>,10indices: TheWorldIndices,11}12impl<T: 'static> Clone for TheWorldPre<T> {13fn clone(&self) -> Self {14Self {15instance_pre: self.instance_pre.clone(),16indices: self.indices.clone(),17}18}19}20impl<_T: 'static> TheWorldPre<_T> {21/// Creates a new copy of `TheWorldPre` bindings which can then22/// be used to instantiate into a particular store.23///24/// This method may fail if the component behind `instance_pre`25/// does not have the required exports.26pub fn new(27instance_pre: wasmtime::component::InstancePre<_T>,28) -> wasmtime::Result<Self> {29let indices = TheWorldIndices::new(&instance_pre)?;30Ok(Self { instance_pre, indices })31}32pub fn engine(&self) -> &wasmtime::Engine {33self.instance_pre.engine()34}35pub fn instance_pre(&self) -> &wasmtime::component::InstancePre<_T> {36&self.instance_pre37}38/// Instantiates a new instance of [`TheWorld`] within the39/// `store` provided.40///41/// This function will use `self` as the pre-instantiated42/// instance to perform instantiation. Afterwards the preloaded43/// indices in `self` are used to lookup all exports on the44/// resulting instance.45pub fn instantiate(46&self,47mut store: impl wasmtime::AsContextMut<Data = _T>,48) -> wasmtime::Result<TheWorld> {49let mut store = store.as_context_mut();50let instance = self.instance_pre.instantiate(&mut store)?;51self.indices.load(&mut store, &instance)52}53}54impl<_T: Send + 'static> TheWorldPre<_T> {55/// Same as [`Self::instantiate`], except with `async`.56pub async fn instantiate_async(57&self,58mut store: impl wasmtime::AsContextMut<Data = _T>,59) -> wasmtime::Result<TheWorld> {60let mut store = store.as_context_mut();61let instance = self.instance_pre.instantiate_async(&mut store).await?;62self.indices.load(&mut store, &instance)63}64}65/// Auto-generated bindings for index of the exports of66/// `the-world`.67///68/// This is an implementation detail of [`TheWorldPre`] and can69/// be constructed if needed as well.70///71/// For more information see [`TheWorld`] as well.72#[derive(Clone)]73pub struct TheWorldIndices {74interface0: exports::foo::foo::integers::GuestIndices,75}76/// Auto-generated bindings for an instance a component which77/// implements the world `the-world`.78///79/// This structure can be created through a number of means80/// depending on your requirements and what you have on hand:81///82/// * The most convenient way is to use83/// [`TheWorld::instantiate`] which only needs a84/// [`Store`], [`Component`], and [`Linker`].85///86/// * Alternatively you can create a [`TheWorldPre`] ahead of87/// time with a [`Component`] to front-load string lookups88/// of exports once instead of per-instantiation. This89/// method then uses [`TheWorldPre::instantiate`] to90/// create a [`TheWorld`].91///92/// * If you've instantiated the instance yourself already93/// then you can use [`TheWorld::new`].94///95/// These methods are all equivalent to one another and move96/// around the tradeoff of what work is performed when.97///98/// [`Store`]: wasmtime::Store99/// [`Component`]: wasmtime::component::Component100/// [`Linker`]: wasmtime::component::Linker101pub struct TheWorld {102interface0: exports::foo::foo::integers::Guest,103}104const _: () = {105impl TheWorldIndices {106/// Creates a new copy of `TheWorldIndices` bindings which can then107/// be used to instantiate into a particular store.108///109/// This method may fail if the component does not have the110/// required exports.111pub fn new<_T>(112_instance_pre: &wasmtime::component::InstancePre<_T>,113) -> wasmtime::Result<Self> {114let _component = _instance_pre.component();115let _instance_type = _instance_pre.instance_type();116let interface0 = exports::foo::foo::integers::GuestIndices::new(117_instance_pre,118)?;119Ok(TheWorldIndices { interface0 })120}121/// Uses the indices stored in `self` to load an instance122/// of [`TheWorld`] from the instance provided.123///124/// Note that at this time this method will additionally125/// perform type-checks of all exports.126pub fn load(127&self,128mut store: impl wasmtime::AsContextMut,129instance: &wasmtime::component::Instance,130) -> wasmtime::Result<TheWorld> {131let _ = &mut store;132let _instance = instance;133let interface0 = self.interface0.load(&mut store, &_instance)?;134Ok(TheWorld { interface0 })135}136}137impl TheWorld {138/// Convenience wrapper around [`TheWorldPre::new`] and139/// [`TheWorldPre::instantiate`].140pub fn instantiate<_T>(141store: impl wasmtime::AsContextMut<Data = _T>,142component: &wasmtime::component::Component,143linker: &wasmtime::component::Linker<_T>,144) -> wasmtime::Result<TheWorld> {145let pre = linker.instantiate_pre(component)?;146TheWorldPre::new(pre)?.instantiate(store)147}148/// Convenience wrapper around [`TheWorldIndices::new`] and149/// [`TheWorldIndices::load`].150pub fn new(151mut store: impl wasmtime::AsContextMut,152instance: &wasmtime::component::Instance,153) -> wasmtime::Result<TheWorld> {154let indices = TheWorldIndices::new(&instance.instance_pre(&store))?;155indices.load(&mut store, instance)156}157/// Convenience wrapper around [`TheWorldPre::new`] and158/// [`TheWorldPre::instantiate_async`].159pub async fn instantiate_async<_T>(160store: impl wasmtime::AsContextMut<Data = _T>,161component: &wasmtime::component::Component,162linker: &wasmtime::component::Linker<_T>,163) -> wasmtime::Result<TheWorld>164where165_T: Send,166{167let pre = linker.instantiate_pre(component)?;168TheWorldPre::new(pre)?.instantiate_async(store).await169}170pub fn add_to_linker<T, D>(171linker: &mut wasmtime::component::Linker<T>,172host_getter: fn(&mut T) -> D::Data<'_>,173) -> wasmtime::Result<()>174where175D: foo::foo::integers::HostWithStore + Send,176for<'a> D::Data<'a>: foo::foo::integers::Host + Send,177T: 'static + Send,178{179foo::foo::integers::add_to_linker::<T, D>(linker, host_getter)?;180Ok(())181}182pub fn foo_foo_integers(&self) -> &exports::foo::foo::integers::Guest {183&self.interface0184}185}186};187pub mod foo {188pub mod foo {189#[allow(clippy::all)]190pub mod integers {191#[allow(unused_imports)]192use wasmtime::component::__internal::Box;193pub trait HostWithStore: wasmtime::component::HasData + Send {}194impl<_T: ?Sized> HostWithStore for _T195where196_T: wasmtime::component::HasData + Send,197{}198pub trait Host: Send {199fn a1(200&mut self,201x: u8,202) -> impl ::core::future::Future<Output = ()> + Send;203fn a2(204&mut self,205x: i8,206) -> impl ::core::future::Future<Output = ()> + Send;207fn a3(208&mut self,209x: u16,210) -> impl ::core::future::Future<Output = ()> + Send;211fn a4(212&mut self,213x: i16,214) -> impl ::core::future::Future<Output = ()> + Send;215fn a5(216&mut self,217x: u32,218) -> impl ::core::future::Future<Output = ()> + Send;219fn a6(220&mut self,221x: i32,222) -> impl ::core::future::Future<Output = ()> + Send;223fn a7(224&mut self,225x: u64,226) -> impl ::core::future::Future<Output = ()> + Send;227fn a8(228&mut self,229x: i64,230) -> impl ::core::future::Future<Output = ()> + Send;231fn a9(232&mut self,233p1: u8,234p2: i8,235p3: u16,236p4: i16,237p5: u32,238p6: i32,239p7: u64,240p8: i64,241) -> impl ::core::future::Future<Output = ()> + Send;242fn r1(&mut self) -> impl ::core::future::Future<Output = u8> + Send;243fn r2(&mut self) -> impl ::core::future::Future<Output = i8> + Send;244fn r3(&mut self) -> impl ::core::future::Future<Output = u16> + Send;245fn r4(&mut self) -> impl ::core::future::Future<Output = i16> + Send;246fn r5(&mut self) -> impl ::core::future::Future<Output = u32> + Send;247fn r6(&mut self) -> impl ::core::future::Future<Output = i32> + Send;248fn r7(&mut self) -> impl ::core::future::Future<Output = u64> + Send;249fn r8(&mut self) -> impl ::core::future::Future<Output = i64> + Send;250fn pair_ret(251&mut self,252) -> impl ::core::future::Future<Output = (i64, u8)> + Send;253}254impl<_T: Host + ?Sized + Send> Host for &mut _T {255fn a1(256&mut self,257x: u8,258) -> impl ::core::future::Future<Output = ()> + Send {259async move { Host::a1(*self, x).await }260}261fn a2(262&mut self,263x: i8,264) -> impl ::core::future::Future<Output = ()> + Send {265async move { Host::a2(*self, x).await }266}267fn a3(268&mut self,269x: u16,270) -> impl ::core::future::Future<Output = ()> + Send {271async move { Host::a3(*self, x).await }272}273fn a4(274&mut self,275x: i16,276) -> impl ::core::future::Future<Output = ()> + Send {277async move { Host::a4(*self, x).await }278}279fn a5(280&mut self,281x: u32,282) -> impl ::core::future::Future<Output = ()> + Send {283async move { Host::a5(*self, x).await }284}285fn a6(286&mut self,287x: i32,288) -> impl ::core::future::Future<Output = ()> + Send {289async move { Host::a6(*self, x).await }290}291fn a7(292&mut self,293x: u64,294) -> impl ::core::future::Future<Output = ()> + Send {295async move { Host::a7(*self, x).await }296}297fn a8(298&mut self,299x: i64,300) -> impl ::core::future::Future<Output = ()> + Send {301async move { Host::a8(*self, x).await }302}303fn a9(304&mut self,305p1: u8,306p2: i8,307p3: u16,308p4: i16,309p5: u32,310p6: i32,311p7: u64,312p8: i64,313) -> impl ::core::future::Future<Output = ()> + Send {314async move { Host::a9(*self, p1, p2, p3, p4, p5, p6, p7, p8).await }315}316fn r1(&mut self) -> impl ::core::future::Future<Output = u8> + Send {317async move { Host::r1(*self).await }318}319fn r2(&mut self) -> impl ::core::future::Future<Output = i8> + Send {320async move { Host::r2(*self).await }321}322fn r3(&mut self) -> impl ::core::future::Future<Output = u16> + Send {323async move { Host::r3(*self).await }324}325fn r4(&mut self) -> impl ::core::future::Future<Output = i16> + Send {326async move { Host::r4(*self).await }327}328fn r5(&mut self) -> impl ::core::future::Future<Output = u32> + Send {329async move { Host::r5(*self).await }330}331fn r6(&mut self) -> impl ::core::future::Future<Output = i32> + Send {332async move { Host::r6(*self).await }333}334fn r7(&mut self) -> impl ::core::future::Future<Output = u64> + Send {335async move { Host::r7(*self).await }336}337fn r8(&mut self) -> impl ::core::future::Future<Output = i64> + Send {338async move { Host::r8(*self).await }339}340fn pair_ret(341&mut self,342) -> impl ::core::future::Future<Output = (i64, u8)> + Send {343async move { Host::pair_ret(*self).await }344}345}346pub fn add_to_linker<T, D>(347linker: &mut wasmtime::component::Linker<T>,348host_getter: fn(&mut T) -> D::Data<'_>,349) -> wasmtime::Result<()>350where351D: HostWithStore,352for<'a> D::Data<'a>: Host,353T: 'static + Send,354{355let mut inst = linker.instance("foo:foo/integers")?;356inst.func_wrap_async(357"a1",358move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (u8,)| {359use tracing::Instrument;360let span = tracing::span!(361tracing::Level::TRACE, "wit-bindgen import", module =362"integers", function = "a1",363);364wasmtime::component::__internal::Box::new(365async move {366tracing::event!(367tracing::Level::TRACE, x = tracing::field::debug(& arg0),368"call"369);370let host = &mut host_getter(caller.data_mut());371let r = Host::a1(host, arg0).await;372tracing::event!(373tracing::Level::TRACE, result = tracing::field::debug(& r),374"return"375);376Ok(r)377}378.instrument(span),379)380},381)?;382inst.func_wrap_async(383"a2",384move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (i8,)| {385use tracing::Instrument;386let span = tracing::span!(387tracing::Level::TRACE, "wit-bindgen import", module =388"integers", function = "a2",389);390wasmtime::component::__internal::Box::new(391async move {392tracing::event!(393tracing::Level::TRACE, x = tracing::field::debug(& arg0),394"call"395);396let host = &mut host_getter(caller.data_mut());397let r = Host::a2(host, arg0).await;398tracing::event!(399tracing::Level::TRACE, result = tracing::field::debug(& r),400"return"401);402Ok(r)403}404.instrument(span),405)406},407)?;408inst.func_wrap_async(409"a3",410move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (u16,)| {411use tracing::Instrument;412let span = tracing::span!(413tracing::Level::TRACE, "wit-bindgen import", module =414"integers", function = "a3",415);416wasmtime::component::__internal::Box::new(417async move {418tracing::event!(419tracing::Level::TRACE, x = tracing::field::debug(& arg0),420"call"421);422let host = &mut host_getter(caller.data_mut());423let r = Host::a3(host, arg0).await;424tracing::event!(425tracing::Level::TRACE, result = tracing::field::debug(& r),426"return"427);428Ok(r)429}430.instrument(span),431)432},433)?;434inst.func_wrap_async(435"a4",436move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (i16,)| {437use tracing::Instrument;438let span = tracing::span!(439tracing::Level::TRACE, "wit-bindgen import", module =440"integers", function = "a4",441);442wasmtime::component::__internal::Box::new(443async move {444tracing::event!(445tracing::Level::TRACE, x = tracing::field::debug(& arg0),446"call"447);448let host = &mut host_getter(caller.data_mut());449let r = Host::a4(host, arg0).await;450tracing::event!(451tracing::Level::TRACE, result = tracing::field::debug(& r),452"return"453);454Ok(r)455}456.instrument(span),457)458},459)?;460inst.func_wrap_async(461"a5",462move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (u32,)| {463use tracing::Instrument;464let span = tracing::span!(465tracing::Level::TRACE, "wit-bindgen import", module =466"integers", function = "a5",467);468wasmtime::component::__internal::Box::new(469async move {470tracing::event!(471tracing::Level::TRACE, x = tracing::field::debug(& arg0),472"call"473);474let host = &mut host_getter(caller.data_mut());475let r = Host::a5(host, arg0).await;476tracing::event!(477tracing::Level::TRACE, result = tracing::field::debug(& r),478"return"479);480Ok(r)481}482.instrument(span),483)484},485)?;486inst.func_wrap_async(487"a6",488move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (i32,)| {489use tracing::Instrument;490let span = tracing::span!(491tracing::Level::TRACE, "wit-bindgen import", module =492"integers", function = "a6",493);494wasmtime::component::__internal::Box::new(495async move {496tracing::event!(497tracing::Level::TRACE, x = tracing::field::debug(& arg0),498"call"499);500let host = &mut host_getter(caller.data_mut());501let r = Host::a6(host, arg0).await;502tracing::event!(503tracing::Level::TRACE, result = tracing::field::debug(& r),504"return"505);506Ok(r)507}508.instrument(span),509)510},511)?;512inst.func_wrap_async(513"a7",514move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (u64,)| {515use tracing::Instrument;516let span = tracing::span!(517tracing::Level::TRACE, "wit-bindgen import", module =518"integers", function = "a7",519);520wasmtime::component::__internal::Box::new(521async move {522tracing::event!(523tracing::Level::TRACE, x = tracing::field::debug(& arg0),524"call"525);526let host = &mut host_getter(caller.data_mut());527let r = Host::a7(host, arg0).await;528tracing::event!(529tracing::Level::TRACE, result = tracing::field::debug(& r),530"return"531);532Ok(r)533}534.instrument(span),535)536},537)?;538inst.func_wrap_async(539"a8",540move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (i64,)| {541use tracing::Instrument;542let span = tracing::span!(543tracing::Level::TRACE, "wit-bindgen import", module =544"integers", function = "a8",545);546wasmtime::component::__internal::Box::new(547async move {548tracing::event!(549tracing::Level::TRACE, x = tracing::field::debug(& arg0),550"call"551);552let host = &mut host_getter(caller.data_mut());553let r = Host::a8(host, arg0).await;554tracing::event!(555tracing::Level::TRACE, result = tracing::field::debug(& r),556"return"557);558Ok(r)559}560.instrument(span),561)562},563)?;564inst.func_wrap_async(565"a9",566move |567mut caller: wasmtime::StoreContextMut<'_, T>,568(569arg0,570arg1,571arg2,572arg3,573arg4,574arg5,575arg6,576arg7,577): (u8, i8, u16, i16, u32, i32, u64, i64)|578{579use tracing::Instrument;580let span = tracing::span!(581tracing::Level::TRACE, "wit-bindgen import", module =582"integers", function = "a9",583);584wasmtime::component::__internal::Box::new(585async move {586tracing::event!(587tracing::Level::TRACE, p1 = tracing::field::debug(& arg0),588p2 = tracing::field::debug(& arg1), p3 =589tracing::field::debug(& arg2), p4 = tracing::field::debug(&590arg3), p5 = tracing::field::debug(& arg4), p6 =591tracing::field::debug(& arg5), p7 = tracing::field::debug(&592arg6), p8 = tracing::field::debug(& arg7), "call"593);594let host = &mut host_getter(caller.data_mut());595let r = Host::a9(596host,597arg0,598arg1,599arg2,600arg3,601arg4,602arg5,603arg6,604arg7,605)606.await;607tracing::event!(608tracing::Level::TRACE, result = tracing::field::debug(& r),609"return"610);611Ok(r)612}613.instrument(span),614)615},616)?;617inst.func_wrap_async(618"r1",619move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {620use tracing::Instrument;621let span = tracing::span!(622tracing::Level::TRACE, "wit-bindgen import", module =623"integers", function = "r1",624);625wasmtime::component::__internal::Box::new(626async move {627tracing::event!(tracing::Level::TRACE, "call");628let host = &mut host_getter(caller.data_mut());629let r = Host::r1(host).await;630tracing::event!(631tracing::Level::TRACE, result = tracing::field::debug(& r),632"return"633);634Ok((r,))635}636.instrument(span),637)638},639)?;640inst.func_wrap_async(641"r2",642move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {643use tracing::Instrument;644let span = tracing::span!(645tracing::Level::TRACE, "wit-bindgen import", module =646"integers", function = "r2",647);648wasmtime::component::__internal::Box::new(649async move {650tracing::event!(tracing::Level::TRACE, "call");651let host = &mut host_getter(caller.data_mut());652let r = Host::r2(host).await;653tracing::event!(654tracing::Level::TRACE, result = tracing::field::debug(& r),655"return"656);657Ok((r,))658}659.instrument(span),660)661},662)?;663inst.func_wrap_async(664"r3",665move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {666use tracing::Instrument;667let span = tracing::span!(668tracing::Level::TRACE, "wit-bindgen import", module =669"integers", function = "r3",670);671wasmtime::component::__internal::Box::new(672async move {673tracing::event!(tracing::Level::TRACE, "call");674let host = &mut host_getter(caller.data_mut());675let r = Host::r3(host).await;676tracing::event!(677tracing::Level::TRACE, result = tracing::field::debug(& r),678"return"679);680Ok((r,))681}682.instrument(span),683)684},685)?;686inst.func_wrap_async(687"r4",688move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {689use tracing::Instrument;690let span = tracing::span!(691tracing::Level::TRACE, "wit-bindgen import", module =692"integers", function = "r4",693);694wasmtime::component::__internal::Box::new(695async move {696tracing::event!(tracing::Level::TRACE, "call");697let host = &mut host_getter(caller.data_mut());698let r = Host::r4(host).await;699tracing::event!(700tracing::Level::TRACE, result = tracing::field::debug(& r),701"return"702);703Ok((r,))704}705.instrument(span),706)707},708)?;709inst.func_wrap_async(710"r5",711move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {712use tracing::Instrument;713let span = tracing::span!(714tracing::Level::TRACE, "wit-bindgen import", module =715"integers", function = "r5",716);717wasmtime::component::__internal::Box::new(718async move {719tracing::event!(tracing::Level::TRACE, "call");720let host = &mut host_getter(caller.data_mut());721let r = Host::r5(host).await;722tracing::event!(723tracing::Level::TRACE, result = tracing::field::debug(& r),724"return"725);726Ok((r,))727}728.instrument(span),729)730},731)?;732inst.func_wrap_async(733"r6",734move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {735use tracing::Instrument;736let span = tracing::span!(737tracing::Level::TRACE, "wit-bindgen import", module =738"integers", function = "r6",739);740wasmtime::component::__internal::Box::new(741async move {742tracing::event!(tracing::Level::TRACE, "call");743let host = &mut host_getter(caller.data_mut());744let r = Host::r6(host).await;745tracing::event!(746tracing::Level::TRACE, result = tracing::field::debug(& r),747"return"748);749Ok((r,))750}751.instrument(span),752)753},754)?;755inst.func_wrap_async(756"r7",757move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {758use tracing::Instrument;759let span = tracing::span!(760tracing::Level::TRACE, "wit-bindgen import", module =761"integers", function = "r7",762);763wasmtime::component::__internal::Box::new(764async move {765tracing::event!(tracing::Level::TRACE, "call");766let host = &mut host_getter(caller.data_mut());767let r = Host::r7(host).await;768tracing::event!(769tracing::Level::TRACE, result = tracing::field::debug(& r),770"return"771);772Ok((r,))773}774.instrument(span),775)776},777)?;778inst.func_wrap_async(779"r8",780move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {781use tracing::Instrument;782let span = tracing::span!(783tracing::Level::TRACE, "wit-bindgen import", module =784"integers", function = "r8",785);786wasmtime::component::__internal::Box::new(787async move {788tracing::event!(tracing::Level::TRACE, "call");789let host = &mut host_getter(caller.data_mut());790let r = Host::r8(host).await;791tracing::event!(792tracing::Level::TRACE, result = tracing::field::debug(& r),793"return"794);795Ok((r,))796}797.instrument(span),798)799},800)?;801inst.func_wrap_async(802"pair-ret",803move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {804use tracing::Instrument;805let span = tracing::span!(806tracing::Level::TRACE, "wit-bindgen import", module =807"integers", function = "pair-ret",808);809wasmtime::component::__internal::Box::new(810async move {811tracing::event!(tracing::Level::TRACE, "call");812let host = &mut host_getter(caller.data_mut());813let r = Host::pair_ret(host).await;814tracing::event!(815tracing::Level::TRACE, result = tracing::field::debug(& r),816"return"817);818Ok((r,))819}820.instrument(span),821)822},823)?;824Ok(())825}826}827}828}829pub mod exports {830pub mod foo {831pub mod foo {832#[allow(clippy::all)]833pub mod integers {834#[allow(unused_imports)]835use wasmtime::component::__internal::Box;836#[derive(Clone)]837pub struct Guest {838a1: wasmtime::component::Func,839a2: wasmtime::component::Func,840a3: wasmtime::component::Func,841a4: wasmtime::component::Func,842a5: wasmtime::component::Func,843a6: wasmtime::component::Func,844a7: wasmtime::component::Func,845a8: wasmtime::component::Func,846a9: wasmtime::component::Func,847r1: wasmtime::component::Func,848r2: wasmtime::component::Func,849r3: wasmtime::component::Func,850r4: wasmtime::component::Func,851r5: wasmtime::component::Func,852r6: wasmtime::component::Func,853r7: wasmtime::component::Func,854r8: wasmtime::component::Func,855pair_ret: wasmtime::component::Func,856}857#[derive(Clone)]858pub struct GuestIndices {859a1: wasmtime::component::ComponentExportIndex,860a2: wasmtime::component::ComponentExportIndex,861a3: wasmtime::component::ComponentExportIndex,862a4: wasmtime::component::ComponentExportIndex,863a5: wasmtime::component::ComponentExportIndex,864a6: wasmtime::component::ComponentExportIndex,865a7: wasmtime::component::ComponentExportIndex,866a8: wasmtime::component::ComponentExportIndex,867a9: wasmtime::component::ComponentExportIndex,868r1: wasmtime::component::ComponentExportIndex,869r2: wasmtime::component::ComponentExportIndex,870r3: wasmtime::component::ComponentExportIndex,871r4: wasmtime::component::ComponentExportIndex,872r5: wasmtime::component::ComponentExportIndex,873r6: wasmtime::component::ComponentExportIndex,874r7: wasmtime::component::ComponentExportIndex,875r8: wasmtime::component::ComponentExportIndex,876pair_ret: wasmtime::component::ComponentExportIndex,877}878impl GuestIndices {879/// Constructor for [`GuestIndices`] which takes a880/// [`Component`](wasmtime::component::Component) as input and can be executed881/// before instantiation.882///883/// This constructor can be used to front-load string lookups to find exports884/// within a component.885pub fn new<_T>(886_instance_pre: &wasmtime::component::InstancePre<_T>,887) -> wasmtime::Result<GuestIndices> {888let instance = _instance_pre889.component()890.get_export_index(None, "foo:foo/integers")891.ok_or_else(|| {892wasmtime::format_err!(893"no exported instance named `foo:foo/integers`"894)895})?;896let mut lookup = move |name| {897_instance_pre898.component()899.get_export_index(Some(&instance), name)900.ok_or_else(|| {901wasmtime::format_err!(902"instance export `foo:foo/integers` does \903not have export `{name}`"904)905})906};907let _ = &mut lookup;908let a1 = lookup("a1")?;909let a2 = lookup("a2")?;910let a3 = lookup("a3")?;911let a4 = lookup("a4")?;912let a5 = lookup("a5")?;913let a6 = lookup("a6")?;914let a7 = lookup("a7")?;915let a8 = lookup("a8")?;916let a9 = lookup("a9")?;917let r1 = lookup("r1")?;918let r2 = lookup("r2")?;919let r3 = lookup("r3")?;920let r4 = lookup("r4")?;921let r5 = lookup("r5")?;922let r6 = lookup("r6")?;923let r7 = lookup("r7")?;924let r8 = lookup("r8")?;925let pair_ret = lookup("pair-ret")?;926Ok(GuestIndices {927a1,928a2,929a3,930a4,931a5,932a6,933a7,934a8,935a9,936r1,937r2,938r3,939r4,940r5,941r6,942r7,943r8,944pair_ret,945})946}947pub fn load(948&self,949mut store: impl wasmtime::AsContextMut,950instance: &wasmtime::component::Instance,951) -> wasmtime::Result<Guest> {952let _instance = instance;953let _instance_pre = _instance.instance_pre(&store);954let _instance_type = _instance_pre.instance_type();955let mut store = store.as_context_mut();956let _ = &mut store;957let a1 = *_instance958.get_typed_func::<(u8,), ()>(&mut store, &self.a1)?959.func();960let a2 = *_instance961.get_typed_func::<(i8,), ()>(&mut store, &self.a2)?962.func();963let a3 = *_instance964.get_typed_func::<(u16,), ()>(&mut store, &self.a3)?965.func();966let a4 = *_instance967.get_typed_func::<(i16,), ()>(&mut store, &self.a4)?968.func();969let a5 = *_instance970.get_typed_func::<(u32,), ()>(&mut store, &self.a5)?971.func();972let a6 = *_instance973.get_typed_func::<(i32,), ()>(&mut store, &self.a6)?974.func();975let a7 = *_instance976.get_typed_func::<(u64,), ()>(&mut store, &self.a7)?977.func();978let a8 = *_instance979.get_typed_func::<(i64,), ()>(&mut store, &self.a8)?980.func();981let a9 = *_instance982.get_typed_func::<983(u8, i8, u16, i16, u32, i32, u64, i64),984(),985>(&mut store, &self.a9)?986.func();987let r1 = *_instance988.get_typed_func::<(), (u8,)>(&mut store, &self.r1)?989.func();990let r2 = *_instance991.get_typed_func::<(), (i8,)>(&mut store, &self.r2)?992.func();993let r3 = *_instance994.get_typed_func::<(), (u16,)>(&mut store, &self.r3)?995.func();996let r4 = *_instance997.get_typed_func::<(), (i16,)>(&mut store, &self.r4)?998.func();999let r5 = *_instance1000.get_typed_func::<(), (u32,)>(&mut store, &self.r5)?1001.func();1002let r6 = *_instance1003.get_typed_func::<(), (i32,)>(&mut store, &self.r6)?1004.func();1005let r7 = *_instance1006.get_typed_func::<(), (u64,)>(&mut store, &self.r7)?1007.func();1008let r8 = *_instance1009.get_typed_func::<(), (i64,)>(&mut store, &self.r8)?1010.func();1011let pair_ret = *_instance1012.get_typed_func::<1013(),1014((i64, u8),),1015>(&mut store, &self.pair_ret)?1016.func();1017Ok(Guest {1018a1,1019a2,1020a3,1021a4,1022a5,1023a6,1024a7,1025a8,1026a9,1027r1,1028r2,1029r3,1030r4,1031r5,1032r6,1033r7,1034r8,1035pair_ret,1036})1037}1038}1039impl Guest {1040pub async fn call_a1<S: wasmtime::AsContextMut>(1041&self,1042mut store: S,1043arg0: u8,1044) -> wasmtime::Result<()>1045where1046<S as wasmtime::AsContext>::Data: Send,1047{1048use tracing::Instrument;1049let span = tracing::span!(1050tracing::Level::TRACE, "wit-bindgen export", module =1051"foo:foo/integers", function = "a1",1052);1053let callee = unsafe {1054wasmtime::component::TypedFunc::<1055(u8,),1056(),1057>::new_unchecked(self.a1)1058};1059let () = callee1060.call_async(store.as_context_mut(), (arg0,))1061.instrument(span.clone())1062.await?;1063Ok(())1064}1065pub async fn call_a2<S: wasmtime::AsContextMut>(1066&self,1067mut store: S,1068arg0: i8,1069) -> wasmtime::Result<()>1070where1071<S as wasmtime::AsContext>::Data: Send,1072{1073use tracing::Instrument;1074let span = tracing::span!(1075tracing::Level::TRACE, "wit-bindgen export", module =1076"foo:foo/integers", function = "a2",1077);1078let callee = unsafe {1079wasmtime::component::TypedFunc::<1080(i8,),1081(),1082>::new_unchecked(self.a2)1083};1084let () = callee1085.call_async(store.as_context_mut(), (arg0,))1086.instrument(span.clone())1087.await?;1088Ok(())1089}1090pub async fn call_a3<S: wasmtime::AsContextMut>(1091&self,1092mut store: S,1093arg0: u16,1094) -> wasmtime::Result<()>1095where1096<S as wasmtime::AsContext>::Data: Send,1097{1098use tracing::Instrument;1099let span = tracing::span!(1100tracing::Level::TRACE, "wit-bindgen export", module =1101"foo:foo/integers", function = "a3",1102);1103let callee = unsafe {1104wasmtime::component::TypedFunc::<1105(u16,),1106(),1107>::new_unchecked(self.a3)1108};1109let () = callee1110.call_async(store.as_context_mut(), (arg0,))1111.instrument(span.clone())1112.await?;1113Ok(())1114}1115pub async fn call_a4<S: wasmtime::AsContextMut>(1116&self,1117mut store: S,1118arg0: i16,1119) -> wasmtime::Result<()>1120where1121<S as wasmtime::AsContext>::Data: Send,1122{1123use tracing::Instrument;1124let span = tracing::span!(1125tracing::Level::TRACE, "wit-bindgen export", module =1126"foo:foo/integers", function = "a4",1127);1128let callee = unsafe {1129wasmtime::component::TypedFunc::<1130(i16,),1131(),1132>::new_unchecked(self.a4)1133};1134let () = callee1135.call_async(store.as_context_mut(), (arg0,))1136.instrument(span.clone())1137.await?;1138Ok(())1139}1140pub async fn call_a5<S: wasmtime::AsContextMut>(1141&self,1142mut store: S,1143arg0: u32,1144) -> wasmtime::Result<()>1145where1146<S as wasmtime::AsContext>::Data: Send,1147{1148use tracing::Instrument;1149let span = tracing::span!(1150tracing::Level::TRACE, "wit-bindgen export", module =1151"foo:foo/integers", function = "a5",1152);1153let callee = unsafe {1154wasmtime::component::TypedFunc::<1155(u32,),1156(),1157>::new_unchecked(self.a5)1158};1159let () = callee1160.call_async(store.as_context_mut(), (arg0,))1161.instrument(span.clone())1162.await?;1163Ok(())1164}1165pub async fn call_a6<S: wasmtime::AsContextMut>(1166&self,1167mut store: S,1168arg0: i32,1169) -> wasmtime::Result<()>1170where1171<S as wasmtime::AsContext>::Data: Send,1172{1173use tracing::Instrument;1174let span = tracing::span!(1175tracing::Level::TRACE, "wit-bindgen export", module =1176"foo:foo/integers", function = "a6",1177);1178let callee = unsafe {1179wasmtime::component::TypedFunc::<1180(i32,),1181(),1182>::new_unchecked(self.a6)1183};1184let () = callee1185.call_async(store.as_context_mut(), (arg0,))1186.instrument(span.clone())1187.await?;1188Ok(())1189}1190pub async fn call_a7<S: wasmtime::AsContextMut>(1191&self,1192mut store: S,1193arg0: u64,1194) -> wasmtime::Result<()>1195where1196<S as wasmtime::AsContext>::Data: Send,1197{1198use tracing::Instrument;1199let span = tracing::span!(1200tracing::Level::TRACE, "wit-bindgen export", module =1201"foo:foo/integers", function = "a7",1202);1203let callee = unsafe {1204wasmtime::component::TypedFunc::<1205(u64,),1206(),1207>::new_unchecked(self.a7)1208};1209let () = callee1210.call_async(store.as_context_mut(), (arg0,))1211.instrument(span.clone())1212.await?;1213Ok(())1214}1215pub async fn call_a8<S: wasmtime::AsContextMut>(1216&self,1217mut store: S,1218arg0: i64,1219) -> wasmtime::Result<()>1220where1221<S as wasmtime::AsContext>::Data: Send,1222{1223use tracing::Instrument;1224let span = tracing::span!(1225tracing::Level::TRACE, "wit-bindgen export", module =1226"foo:foo/integers", function = "a8",1227);1228let callee = unsafe {1229wasmtime::component::TypedFunc::<1230(i64,),1231(),1232>::new_unchecked(self.a8)1233};1234let () = callee1235.call_async(store.as_context_mut(), (arg0,))1236.instrument(span.clone())1237.await?;1238Ok(())1239}1240pub async fn call_a9<S: wasmtime::AsContextMut>(1241&self,1242mut store: S,1243arg0: u8,1244arg1: i8,1245arg2: u16,1246arg3: i16,1247arg4: u32,1248arg5: i32,1249arg6: u64,1250arg7: i64,1251) -> wasmtime::Result<()>1252where1253<S as wasmtime::AsContext>::Data: Send,1254{1255use tracing::Instrument;1256let span = tracing::span!(1257tracing::Level::TRACE, "wit-bindgen export", module =1258"foo:foo/integers", function = "a9",1259);1260let callee = unsafe {1261wasmtime::component::TypedFunc::<1262(u8, i8, u16, i16, u32, i32, u64, i64),1263(),1264>::new_unchecked(self.a9)1265};1266let () = callee1267.call_async(1268store.as_context_mut(),1269(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7),1270)1271.instrument(span.clone())1272.await?;1273Ok(())1274}1275pub async fn call_r1<S: wasmtime::AsContextMut>(1276&self,1277mut store: S,1278) -> wasmtime::Result<u8>1279where1280<S as wasmtime::AsContext>::Data: Send,1281{1282use tracing::Instrument;1283let span = tracing::span!(1284tracing::Level::TRACE, "wit-bindgen export", module =1285"foo:foo/integers", function = "r1",1286);1287let callee = unsafe {1288wasmtime::component::TypedFunc::<1289(),1290(u8,),1291>::new_unchecked(self.r1)1292};1293let (ret0,) = callee1294.call_async(store.as_context_mut(), ())1295.instrument(span.clone())1296.await?;1297Ok(ret0)1298}1299pub async fn call_r2<S: wasmtime::AsContextMut>(1300&self,1301mut store: S,1302) -> wasmtime::Result<i8>1303where1304<S as wasmtime::AsContext>::Data: Send,1305{1306use tracing::Instrument;1307let span = tracing::span!(1308tracing::Level::TRACE, "wit-bindgen export", module =1309"foo:foo/integers", function = "r2",1310);1311let callee = unsafe {1312wasmtime::component::TypedFunc::<1313(),1314(i8,),1315>::new_unchecked(self.r2)1316};1317let (ret0,) = callee1318.call_async(store.as_context_mut(), ())1319.instrument(span.clone())1320.await?;1321Ok(ret0)1322}1323pub async fn call_r3<S: wasmtime::AsContextMut>(1324&self,1325mut store: S,1326) -> wasmtime::Result<u16>1327where1328<S as wasmtime::AsContext>::Data: Send,1329{1330use tracing::Instrument;1331let span = tracing::span!(1332tracing::Level::TRACE, "wit-bindgen export", module =1333"foo:foo/integers", function = "r3",1334);1335let callee = unsafe {1336wasmtime::component::TypedFunc::<1337(),1338(u16,),1339>::new_unchecked(self.r3)1340};1341let (ret0,) = callee1342.call_async(store.as_context_mut(), ())1343.instrument(span.clone())1344.await?;1345Ok(ret0)1346}1347pub async fn call_r4<S: wasmtime::AsContextMut>(1348&self,1349mut store: S,1350) -> wasmtime::Result<i16>1351where1352<S as wasmtime::AsContext>::Data: Send,1353{1354use tracing::Instrument;1355let span = tracing::span!(1356tracing::Level::TRACE, "wit-bindgen export", module =1357"foo:foo/integers", function = "r4",1358);1359let callee = unsafe {1360wasmtime::component::TypedFunc::<1361(),1362(i16,),1363>::new_unchecked(self.r4)1364};1365let (ret0,) = callee1366.call_async(store.as_context_mut(), ())1367.instrument(span.clone())1368.await?;1369Ok(ret0)1370}1371pub async fn call_r5<S: wasmtime::AsContextMut>(1372&self,1373mut store: S,1374) -> wasmtime::Result<u32>1375where1376<S as wasmtime::AsContext>::Data: Send,1377{1378use tracing::Instrument;1379let span = tracing::span!(1380tracing::Level::TRACE, "wit-bindgen export", module =1381"foo:foo/integers", function = "r5",1382);1383let callee = unsafe {1384wasmtime::component::TypedFunc::<1385(),1386(u32,),1387>::new_unchecked(self.r5)1388};1389let (ret0,) = callee1390.call_async(store.as_context_mut(), ())1391.instrument(span.clone())1392.await?;1393Ok(ret0)1394}1395pub async fn call_r6<S: wasmtime::AsContextMut>(1396&self,1397mut store: S,1398) -> wasmtime::Result<i32>1399where1400<S as wasmtime::AsContext>::Data: Send,1401{1402use tracing::Instrument;1403let span = tracing::span!(1404tracing::Level::TRACE, "wit-bindgen export", module =1405"foo:foo/integers", function = "r6",1406);1407let callee = unsafe {1408wasmtime::component::TypedFunc::<1409(),1410(i32,),1411>::new_unchecked(self.r6)1412};1413let (ret0,) = callee1414.call_async(store.as_context_mut(), ())1415.instrument(span.clone())1416.await?;1417Ok(ret0)1418}1419pub async fn call_r7<S: wasmtime::AsContextMut>(1420&self,1421mut store: S,1422) -> wasmtime::Result<u64>1423where1424<S as wasmtime::AsContext>::Data: Send,1425{1426use tracing::Instrument;1427let span = tracing::span!(1428tracing::Level::TRACE, "wit-bindgen export", module =1429"foo:foo/integers", function = "r7",1430);1431let callee = unsafe {1432wasmtime::component::TypedFunc::<1433(),1434(u64,),1435>::new_unchecked(self.r7)1436};1437let (ret0,) = callee1438.call_async(store.as_context_mut(), ())1439.instrument(span.clone())1440.await?;1441Ok(ret0)1442}1443pub async fn call_r8<S: wasmtime::AsContextMut>(1444&self,1445mut store: S,1446) -> wasmtime::Result<i64>1447where1448<S as wasmtime::AsContext>::Data: Send,1449{1450use tracing::Instrument;1451let span = tracing::span!(1452tracing::Level::TRACE, "wit-bindgen export", module =1453"foo:foo/integers", function = "r8",1454);1455let callee = unsafe {1456wasmtime::component::TypedFunc::<1457(),1458(i64,),1459>::new_unchecked(self.r8)1460};1461let (ret0,) = callee1462.call_async(store.as_context_mut(), ())1463.instrument(span.clone())1464.await?;1465Ok(ret0)1466}1467pub async fn call_pair_ret<S: wasmtime::AsContextMut>(1468&self,1469mut store: S,1470) -> wasmtime::Result<(i64, u8)>1471where1472<S as wasmtime::AsContext>::Data: Send,1473{1474use tracing::Instrument;1475let span = tracing::span!(1476tracing::Level::TRACE, "wit-bindgen export", module =1477"foo:foo/integers", function = "pair-ret",1478);1479let callee = unsafe {1480wasmtime::component::TypedFunc::<1481(),1482((i64, u8),),1483>::new_unchecked(self.pair_ret)1484};1485let (ret0,) = callee1486.call_async(store.as_context_mut(), ())1487.instrument(span.clone())1488.await?;1489Ok(ret0)1490}1491}1492}1493}1494}1495}149614971498