Path: blob/main/crates/component-macro/tests/expanded/integers_tracing_async.rs
1692 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 _: () = {105#[allow(unused_imports)]106use wasmtime::component::__internal::anyhow;107impl TheWorldIndices {108/// Creates a new copy of `TheWorldIndices` bindings which can then109/// be used to instantiate into a particular store.110///111/// This method may fail if the component does not have the112/// required exports.113pub fn new<_T>(114_instance_pre: &wasmtime::component::InstancePre<_T>,115) -> wasmtime::Result<Self> {116let _component = _instance_pre.component();117let _instance_type = _instance_pre.instance_type();118let interface0 = exports::foo::foo::integers::GuestIndices::new(119_instance_pre,120)?;121Ok(TheWorldIndices { interface0 })122}123/// Uses the indices stored in `self` to load an instance124/// of [`TheWorld`] from the instance provided.125///126/// Note that at this time this method will additionally127/// perform type-checks of all exports.128pub fn load(129&self,130mut store: impl wasmtime::AsContextMut,131instance: &wasmtime::component::Instance,132) -> wasmtime::Result<TheWorld> {133let _ = &mut store;134let _instance = instance;135let interface0 = self.interface0.load(&mut store, &_instance)?;136Ok(TheWorld { interface0 })137}138}139impl TheWorld {140/// Convenience wrapper around [`TheWorldPre::new`] and141/// [`TheWorldPre::instantiate`].142pub fn instantiate<_T>(143store: impl wasmtime::AsContextMut<Data = _T>,144component: &wasmtime::component::Component,145linker: &wasmtime::component::Linker<_T>,146) -> wasmtime::Result<TheWorld> {147let pre = linker.instantiate_pre(component)?;148TheWorldPre::new(pre)?.instantiate(store)149}150/// Convenience wrapper around [`TheWorldIndices::new`] and151/// [`TheWorldIndices::load`].152pub fn new(153mut store: impl wasmtime::AsContextMut,154instance: &wasmtime::component::Instance,155) -> wasmtime::Result<TheWorld> {156let indices = TheWorldIndices::new(&instance.instance_pre(&store))?;157indices.load(&mut store, instance)158}159/// Convenience wrapper around [`TheWorldPre::new`] and160/// [`TheWorldPre::instantiate_async`].161pub async fn instantiate_async<_T>(162store: impl wasmtime::AsContextMut<Data = _T>,163component: &wasmtime::component::Component,164linker: &wasmtime::component::Linker<_T>,165) -> wasmtime::Result<TheWorld>166where167_T: Send,168{169let pre = linker.instantiate_pre(component)?;170TheWorldPre::new(pre)?.instantiate_async(store).await171}172pub fn add_to_linker<T, D>(173linker: &mut wasmtime::component::Linker<T>,174host_getter: fn(&mut T) -> D::Data<'_>,175) -> wasmtime::Result<()>176where177D: foo::foo::integers::HostWithStore + Send,178for<'a> D::Data<'a>: foo::foo::integers::Host + Send,179T: 'static + Send,180{181foo::foo::integers::add_to_linker::<T, D>(linker, host_getter)?;182Ok(())183}184pub fn foo_foo_integers(&self) -> &exports::foo::foo::integers::Guest {185&self.interface0186}187}188};189pub mod foo {190pub mod foo {191#[allow(clippy::all)]192pub mod integers {193#[allow(unused_imports)]194use wasmtime::component::__internal::{anyhow, Box};195pub trait HostWithStore: wasmtime::component::HasData + Send {}196impl<_T: ?Sized> HostWithStore for _T197where198_T: wasmtime::component::HasData + Send,199{}200pub trait Host: Send {201fn a1(202&mut self,203x: u8,204) -> impl ::core::future::Future<Output = ()> + Send;205fn a2(206&mut self,207x: i8,208) -> impl ::core::future::Future<Output = ()> + Send;209fn a3(210&mut self,211x: u16,212) -> impl ::core::future::Future<Output = ()> + Send;213fn a4(214&mut self,215x: i16,216) -> impl ::core::future::Future<Output = ()> + Send;217fn a5(218&mut self,219x: u32,220) -> impl ::core::future::Future<Output = ()> + Send;221fn a6(222&mut self,223x: i32,224) -> impl ::core::future::Future<Output = ()> + Send;225fn a7(226&mut self,227x: u64,228) -> impl ::core::future::Future<Output = ()> + Send;229fn a8(230&mut self,231x: i64,232) -> impl ::core::future::Future<Output = ()> + Send;233fn a9(234&mut self,235p1: u8,236p2: i8,237p3: u16,238p4: i16,239p5: u32,240p6: i32,241p7: u64,242p8: i64,243) -> impl ::core::future::Future<Output = ()> + Send;244fn r1(&mut self) -> impl ::core::future::Future<Output = u8> + Send;245fn r2(&mut self) -> impl ::core::future::Future<Output = i8> + Send;246fn r3(&mut self) -> impl ::core::future::Future<Output = u16> + Send;247fn r4(&mut self) -> impl ::core::future::Future<Output = i16> + Send;248fn r5(&mut self) -> impl ::core::future::Future<Output = u32> + Send;249fn r6(&mut self) -> impl ::core::future::Future<Output = i32> + Send;250fn r7(&mut self) -> impl ::core::future::Future<Output = u64> + Send;251fn r8(&mut self) -> impl ::core::future::Future<Output = i64> + Send;252fn pair_ret(253&mut self,254) -> impl ::core::future::Future<Output = (i64, u8)> + Send;255}256impl<_T: Host + ?Sized + Send> Host for &mut _T {257fn a1(258&mut self,259x: u8,260) -> impl ::core::future::Future<Output = ()> + Send {261async move { Host::a1(*self, x).await }262}263fn a2(264&mut self,265x: i8,266) -> impl ::core::future::Future<Output = ()> + Send {267async move { Host::a2(*self, x).await }268}269fn a3(270&mut self,271x: u16,272) -> impl ::core::future::Future<Output = ()> + Send {273async move { Host::a3(*self, x).await }274}275fn a4(276&mut self,277x: i16,278) -> impl ::core::future::Future<Output = ()> + Send {279async move { Host::a4(*self, x).await }280}281fn a5(282&mut self,283x: u32,284) -> impl ::core::future::Future<Output = ()> + Send {285async move { Host::a5(*self, x).await }286}287fn a6(288&mut self,289x: i32,290) -> impl ::core::future::Future<Output = ()> + Send {291async move { Host::a6(*self, x).await }292}293fn a7(294&mut self,295x: u64,296) -> impl ::core::future::Future<Output = ()> + Send {297async move { Host::a7(*self, x).await }298}299fn a8(300&mut self,301x: i64,302) -> impl ::core::future::Future<Output = ()> + Send {303async move { Host::a8(*self, x).await }304}305fn a9(306&mut self,307p1: u8,308p2: i8,309p3: u16,310p4: i16,311p5: u32,312p6: i32,313p7: u64,314p8: i64,315) -> impl ::core::future::Future<Output = ()> + Send {316async move { Host::a9(*self, p1, p2, p3, p4, p5, p6, p7, p8).await }317}318fn r1(&mut self) -> impl ::core::future::Future<Output = u8> + Send {319async move { Host::r1(*self).await }320}321fn r2(&mut self) -> impl ::core::future::Future<Output = i8> + Send {322async move { Host::r2(*self).await }323}324fn r3(&mut self) -> impl ::core::future::Future<Output = u16> + Send {325async move { Host::r3(*self).await }326}327fn r4(&mut self) -> impl ::core::future::Future<Output = i16> + Send {328async move { Host::r4(*self).await }329}330fn r5(&mut self) -> impl ::core::future::Future<Output = u32> + Send {331async move { Host::r5(*self).await }332}333fn r6(&mut self) -> impl ::core::future::Future<Output = i32> + Send {334async move { Host::r6(*self).await }335}336fn r7(&mut self) -> impl ::core::future::Future<Output = u64> + Send {337async move { Host::r7(*self).await }338}339fn r8(&mut self) -> impl ::core::future::Future<Output = i64> + Send {340async move { Host::r8(*self).await }341}342fn pair_ret(343&mut self,344) -> impl ::core::future::Future<Output = (i64, u8)> + Send {345async move { Host::pair_ret(*self).await }346}347}348pub fn add_to_linker<T, D>(349linker: &mut wasmtime::component::Linker<T>,350host_getter: fn(&mut T) -> D::Data<'_>,351) -> wasmtime::Result<()>352where353D: HostWithStore,354for<'a> D::Data<'a>: Host,355T: 'static + Send,356{357let mut inst = linker.instance("foo:foo/integers")?;358inst.func_wrap_async(359"a1",360move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (u8,)| {361use tracing::Instrument;362let span = tracing::span!(363tracing::Level::TRACE, "wit-bindgen import", module =364"integers", function = "a1",365);366wasmtime::component::__internal::Box::new(367async move {368tracing::event!(369tracing::Level::TRACE, x = tracing::field::debug(& arg0),370"call"371);372let host = &mut host_getter(caller.data_mut());373let r = Host::a1(host, arg0).await;374tracing::event!(375tracing::Level::TRACE, result = tracing::field::debug(& r),376"return"377);378Ok(r)379}380.instrument(span),381)382},383)?;384inst.func_wrap_async(385"a2",386move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (i8,)| {387use tracing::Instrument;388let span = tracing::span!(389tracing::Level::TRACE, "wit-bindgen import", module =390"integers", function = "a2",391);392wasmtime::component::__internal::Box::new(393async move {394tracing::event!(395tracing::Level::TRACE, x = tracing::field::debug(& arg0),396"call"397);398let host = &mut host_getter(caller.data_mut());399let r = Host::a2(host, arg0).await;400tracing::event!(401tracing::Level::TRACE, result = tracing::field::debug(& r),402"return"403);404Ok(r)405}406.instrument(span),407)408},409)?;410inst.func_wrap_async(411"a3",412move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (u16,)| {413use tracing::Instrument;414let span = tracing::span!(415tracing::Level::TRACE, "wit-bindgen import", module =416"integers", function = "a3",417);418wasmtime::component::__internal::Box::new(419async move {420tracing::event!(421tracing::Level::TRACE, x = tracing::field::debug(& arg0),422"call"423);424let host = &mut host_getter(caller.data_mut());425let r = Host::a3(host, arg0).await;426tracing::event!(427tracing::Level::TRACE, result = tracing::field::debug(& r),428"return"429);430Ok(r)431}432.instrument(span),433)434},435)?;436inst.func_wrap_async(437"a4",438move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (i16,)| {439use tracing::Instrument;440let span = tracing::span!(441tracing::Level::TRACE, "wit-bindgen import", module =442"integers", function = "a4",443);444wasmtime::component::__internal::Box::new(445async move {446tracing::event!(447tracing::Level::TRACE, x = tracing::field::debug(& arg0),448"call"449);450let host = &mut host_getter(caller.data_mut());451let r = Host::a4(host, arg0).await;452tracing::event!(453tracing::Level::TRACE, result = tracing::field::debug(& r),454"return"455);456Ok(r)457}458.instrument(span),459)460},461)?;462inst.func_wrap_async(463"a5",464move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (u32,)| {465use tracing::Instrument;466let span = tracing::span!(467tracing::Level::TRACE, "wit-bindgen import", module =468"integers", function = "a5",469);470wasmtime::component::__internal::Box::new(471async move {472tracing::event!(473tracing::Level::TRACE, x = tracing::field::debug(& arg0),474"call"475);476let host = &mut host_getter(caller.data_mut());477let r = Host::a5(host, arg0).await;478tracing::event!(479tracing::Level::TRACE, result = tracing::field::debug(& r),480"return"481);482Ok(r)483}484.instrument(span),485)486},487)?;488inst.func_wrap_async(489"a6",490move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (i32,)| {491use tracing::Instrument;492let span = tracing::span!(493tracing::Level::TRACE, "wit-bindgen import", module =494"integers", function = "a6",495);496wasmtime::component::__internal::Box::new(497async move {498tracing::event!(499tracing::Level::TRACE, x = tracing::field::debug(& arg0),500"call"501);502let host = &mut host_getter(caller.data_mut());503let r = Host::a6(host, arg0).await;504tracing::event!(505tracing::Level::TRACE, result = tracing::field::debug(& r),506"return"507);508Ok(r)509}510.instrument(span),511)512},513)?;514inst.func_wrap_async(515"a7",516move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (u64,)| {517use tracing::Instrument;518let span = tracing::span!(519tracing::Level::TRACE, "wit-bindgen import", module =520"integers", function = "a7",521);522wasmtime::component::__internal::Box::new(523async move {524tracing::event!(525tracing::Level::TRACE, x = tracing::field::debug(& arg0),526"call"527);528let host = &mut host_getter(caller.data_mut());529let r = Host::a7(host, arg0).await;530tracing::event!(531tracing::Level::TRACE, result = tracing::field::debug(& r),532"return"533);534Ok(r)535}536.instrument(span),537)538},539)?;540inst.func_wrap_async(541"a8",542move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (i64,)| {543use tracing::Instrument;544let span = tracing::span!(545tracing::Level::TRACE, "wit-bindgen import", module =546"integers", function = "a8",547);548wasmtime::component::__internal::Box::new(549async move {550tracing::event!(551tracing::Level::TRACE, x = tracing::field::debug(& arg0),552"call"553);554let host = &mut host_getter(caller.data_mut());555let r = Host::a8(host, arg0).await;556tracing::event!(557tracing::Level::TRACE, result = tracing::field::debug(& r),558"return"559);560Ok(r)561}562.instrument(span),563)564},565)?;566inst.func_wrap_async(567"a9",568move |569mut caller: wasmtime::StoreContextMut<'_, T>,570(571arg0,572arg1,573arg2,574arg3,575arg4,576arg5,577arg6,578arg7,579): (u8, i8, u16, i16, u32, i32, u64, i64)|580{581use tracing::Instrument;582let span = tracing::span!(583tracing::Level::TRACE, "wit-bindgen import", module =584"integers", function = "a9",585);586wasmtime::component::__internal::Box::new(587async move {588tracing::event!(589tracing::Level::TRACE, p1 = tracing::field::debug(& arg0),590p2 = tracing::field::debug(& arg1), p3 =591tracing::field::debug(& arg2), p4 = tracing::field::debug(&592arg3), p5 = tracing::field::debug(& arg4), p6 =593tracing::field::debug(& arg5), p7 = tracing::field::debug(&594arg6), p8 = tracing::field::debug(& arg7), "call"595);596let host = &mut host_getter(caller.data_mut());597let r = Host::a9(598host,599arg0,600arg1,601arg2,602arg3,603arg4,604arg5,605arg6,606arg7,607)608.await;609tracing::event!(610tracing::Level::TRACE, result = tracing::field::debug(& r),611"return"612);613Ok(r)614}615.instrument(span),616)617},618)?;619inst.func_wrap_async(620"r1",621move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {622use tracing::Instrument;623let span = tracing::span!(624tracing::Level::TRACE, "wit-bindgen import", module =625"integers", function = "r1",626);627wasmtime::component::__internal::Box::new(628async move {629tracing::event!(tracing::Level::TRACE, "call");630let host = &mut host_getter(caller.data_mut());631let r = Host::r1(host).await;632tracing::event!(633tracing::Level::TRACE, result = tracing::field::debug(& r),634"return"635);636Ok((r,))637}638.instrument(span),639)640},641)?;642inst.func_wrap_async(643"r2",644move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {645use tracing::Instrument;646let span = tracing::span!(647tracing::Level::TRACE, "wit-bindgen import", module =648"integers", function = "r2",649);650wasmtime::component::__internal::Box::new(651async move {652tracing::event!(tracing::Level::TRACE, "call");653let host = &mut host_getter(caller.data_mut());654let r = Host::r2(host).await;655tracing::event!(656tracing::Level::TRACE, result = tracing::field::debug(& r),657"return"658);659Ok((r,))660}661.instrument(span),662)663},664)?;665inst.func_wrap_async(666"r3",667move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {668use tracing::Instrument;669let span = tracing::span!(670tracing::Level::TRACE, "wit-bindgen import", module =671"integers", function = "r3",672);673wasmtime::component::__internal::Box::new(674async move {675tracing::event!(tracing::Level::TRACE, "call");676let host = &mut host_getter(caller.data_mut());677let r = Host::r3(host).await;678tracing::event!(679tracing::Level::TRACE, result = tracing::field::debug(& r),680"return"681);682Ok((r,))683}684.instrument(span),685)686},687)?;688inst.func_wrap_async(689"r4",690move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {691use tracing::Instrument;692let span = tracing::span!(693tracing::Level::TRACE, "wit-bindgen import", module =694"integers", function = "r4",695);696wasmtime::component::__internal::Box::new(697async move {698tracing::event!(tracing::Level::TRACE, "call");699let host = &mut host_getter(caller.data_mut());700let r = Host::r4(host).await;701tracing::event!(702tracing::Level::TRACE, result = tracing::field::debug(& r),703"return"704);705Ok((r,))706}707.instrument(span),708)709},710)?;711inst.func_wrap_async(712"r5",713move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {714use tracing::Instrument;715let span = tracing::span!(716tracing::Level::TRACE, "wit-bindgen import", module =717"integers", function = "r5",718);719wasmtime::component::__internal::Box::new(720async move {721tracing::event!(tracing::Level::TRACE, "call");722let host = &mut host_getter(caller.data_mut());723let r = Host::r5(host).await;724tracing::event!(725tracing::Level::TRACE, result = tracing::field::debug(& r),726"return"727);728Ok((r,))729}730.instrument(span),731)732},733)?;734inst.func_wrap_async(735"r6",736move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {737use tracing::Instrument;738let span = tracing::span!(739tracing::Level::TRACE, "wit-bindgen import", module =740"integers", function = "r6",741);742wasmtime::component::__internal::Box::new(743async move {744tracing::event!(tracing::Level::TRACE, "call");745let host = &mut host_getter(caller.data_mut());746let r = Host::r6(host).await;747tracing::event!(748tracing::Level::TRACE, result = tracing::field::debug(& r),749"return"750);751Ok((r,))752}753.instrument(span),754)755},756)?;757inst.func_wrap_async(758"r7",759move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {760use tracing::Instrument;761let span = tracing::span!(762tracing::Level::TRACE, "wit-bindgen import", module =763"integers", function = "r7",764);765wasmtime::component::__internal::Box::new(766async move {767tracing::event!(tracing::Level::TRACE, "call");768let host = &mut host_getter(caller.data_mut());769let r = Host::r7(host).await;770tracing::event!(771tracing::Level::TRACE, result = tracing::field::debug(& r),772"return"773);774Ok((r,))775}776.instrument(span),777)778},779)?;780inst.func_wrap_async(781"r8",782move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {783use tracing::Instrument;784let span = tracing::span!(785tracing::Level::TRACE, "wit-bindgen import", module =786"integers", function = "r8",787);788wasmtime::component::__internal::Box::new(789async move {790tracing::event!(tracing::Level::TRACE, "call");791let host = &mut host_getter(caller.data_mut());792let r = Host::r8(host).await;793tracing::event!(794tracing::Level::TRACE, result = tracing::field::debug(& r),795"return"796);797Ok((r,))798}799.instrument(span),800)801},802)?;803inst.func_wrap_async(804"pair-ret",805move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {806use tracing::Instrument;807let span = tracing::span!(808tracing::Level::TRACE, "wit-bindgen import", module =809"integers", function = "pair-ret",810);811wasmtime::component::__internal::Box::new(812async move {813tracing::event!(tracing::Level::TRACE, "call");814let host = &mut host_getter(caller.data_mut());815let r = Host::pair_ret(host).await;816tracing::event!(817tracing::Level::TRACE, result = tracing::field::debug(& r),818"return"819);820Ok((r,))821}822.instrument(span),823)824},825)?;826Ok(())827}828}829}830}831pub mod exports {832pub mod foo {833pub mod foo {834#[allow(clippy::all)]835pub mod integers {836#[allow(unused_imports)]837use wasmtime::component::__internal::{anyhow, Box};838pub struct Guest {839a1: wasmtime::component::Func,840a2: wasmtime::component::Func,841a3: wasmtime::component::Func,842a4: wasmtime::component::Func,843a5: wasmtime::component::Func,844a6: wasmtime::component::Func,845a7: wasmtime::component::Func,846a8: wasmtime::component::Func,847a9: wasmtime::component::Func,848r1: wasmtime::component::Func,849r2: wasmtime::component::Func,850r3: wasmtime::component::Func,851r4: wasmtime::component::Func,852r5: wasmtime::component::Func,853r6: wasmtime::component::Func,854r7: wasmtime::component::Func,855r8: wasmtime::component::Func,856pair_ret: wasmtime::component::Func,857}858#[derive(Clone)]859pub struct GuestIndices {860a1: wasmtime::component::ComponentExportIndex,861a2: wasmtime::component::ComponentExportIndex,862a3: wasmtime::component::ComponentExportIndex,863a4: wasmtime::component::ComponentExportIndex,864a5: wasmtime::component::ComponentExportIndex,865a6: wasmtime::component::ComponentExportIndex,866a7: wasmtime::component::ComponentExportIndex,867a8: wasmtime::component::ComponentExportIndex,868a9: wasmtime::component::ComponentExportIndex,869r1: wasmtime::component::ComponentExportIndex,870r2: wasmtime::component::ComponentExportIndex,871r3: wasmtime::component::ComponentExportIndex,872r4: wasmtime::component::ComponentExportIndex,873r5: wasmtime::component::ComponentExportIndex,874r6: wasmtime::component::ComponentExportIndex,875r7: wasmtime::component::ComponentExportIndex,876r8: wasmtime::component::ComponentExportIndex,877pair_ret: wasmtime::component::ComponentExportIndex,878}879impl GuestIndices {880/// Constructor for [`GuestIndices`] which takes a881/// [`Component`](wasmtime::component::Component) as input and can be executed882/// before instantiation.883///884/// This constructor can be used to front-load string lookups to find exports885/// within a component.886pub fn new<_T>(887_instance_pre: &wasmtime::component::InstancePre<_T>,888) -> wasmtime::Result<GuestIndices> {889let instance = _instance_pre890.component()891.get_export_index(None, "foo:foo/integers")892.ok_or_else(|| {893anyhow::anyhow!(894"no exported instance named `foo:foo/integers`"895)896})?;897let mut lookup = move |name| {898_instance_pre899.component()900.get_export_index(Some(&instance), name)901.ok_or_else(|| {902anyhow::anyhow!(903"instance export `foo:foo/integers` does \904not have export `{name}`"905)906})907};908let _ = &mut lookup;909let a1 = lookup("a1")?;910let a2 = lookup("a2")?;911let a3 = lookup("a3")?;912let a4 = lookup("a4")?;913let a5 = lookup("a5")?;914let a6 = lookup("a6")?;915let a7 = lookup("a7")?;916let a8 = lookup("a8")?;917let a9 = lookup("a9")?;918let r1 = lookup("r1")?;919let r2 = lookup("r2")?;920let r3 = lookup("r3")?;921let r4 = lookup("r4")?;922let r5 = lookup("r5")?;923let r6 = lookup("r6")?;924let r7 = lookup("r7")?;925let r8 = lookup("r8")?;926let pair_ret = lookup("pair-ret")?;927Ok(GuestIndices {928a1,929a2,930a3,931a4,932a5,933a6,934a7,935a8,936a9,937r1,938r2,939r3,940r4,941r5,942r6,943r7,944r8,945pair_ret,946})947}948pub fn load(949&self,950mut store: impl wasmtime::AsContextMut,951instance: &wasmtime::component::Instance,952) -> wasmtime::Result<Guest> {953let _instance = instance;954let _instance_pre = _instance.instance_pre(&store);955let _instance_type = _instance_pre.instance_type();956let mut store = store.as_context_mut();957let _ = &mut store;958let a1 = *_instance959.get_typed_func::<(u8,), ()>(&mut store, &self.a1)?960.func();961let a2 = *_instance962.get_typed_func::<(i8,), ()>(&mut store, &self.a2)?963.func();964let a3 = *_instance965.get_typed_func::<(u16,), ()>(&mut store, &self.a3)?966.func();967let a4 = *_instance968.get_typed_func::<(i16,), ()>(&mut store, &self.a4)?969.func();970let a5 = *_instance971.get_typed_func::<(u32,), ()>(&mut store, &self.a5)?972.func();973let a6 = *_instance974.get_typed_func::<(i32,), ()>(&mut store, &self.a6)?975.func();976let a7 = *_instance977.get_typed_func::<(u64,), ()>(&mut store, &self.a7)?978.func();979let a8 = *_instance980.get_typed_func::<(i64,), ()>(&mut store, &self.a8)?981.func();982let a9 = *_instance983.get_typed_func::<984(u8, i8, u16, i16, u32, i32, u64, i64),985(),986>(&mut store, &self.a9)?987.func();988let r1 = *_instance989.get_typed_func::<(), (u8,)>(&mut store, &self.r1)?990.func();991let r2 = *_instance992.get_typed_func::<(), (i8,)>(&mut store, &self.r2)?993.func();994let r3 = *_instance995.get_typed_func::<(), (u16,)>(&mut store, &self.r3)?996.func();997let r4 = *_instance998.get_typed_func::<(), (i16,)>(&mut store, &self.r4)?999.func();1000let r5 = *_instance1001.get_typed_func::<(), (u32,)>(&mut store, &self.r5)?1002.func();1003let r6 = *_instance1004.get_typed_func::<(), (i32,)>(&mut store, &self.r6)?1005.func();1006let r7 = *_instance1007.get_typed_func::<(), (u64,)>(&mut store, &self.r7)?1008.func();1009let r8 = *_instance1010.get_typed_func::<(), (i64,)>(&mut store, &self.r8)?1011.func();1012let pair_ret = *_instance1013.get_typed_func::<1014(),1015((i64, u8),),1016>(&mut store, &self.pair_ret)?1017.func();1018Ok(Guest {1019a1,1020a2,1021a3,1022a4,1023a5,1024a6,1025a7,1026a8,1027a9,1028r1,1029r2,1030r3,1031r4,1032r5,1033r6,1034r7,1035r8,1036pair_ret,1037})1038}1039}1040impl Guest {1041pub async fn call_a1<S: wasmtime::AsContextMut>(1042&self,1043mut store: S,1044arg0: u8,1045) -> wasmtime::Result<()>1046where1047<S as wasmtime::AsContext>::Data: Send,1048{1049use tracing::Instrument;1050let span = tracing::span!(1051tracing::Level::TRACE, "wit-bindgen export", module =1052"foo:foo/integers", function = "a1",1053);1054let callee = unsafe {1055wasmtime::component::TypedFunc::<1056(u8,),1057(),1058>::new_unchecked(self.a1)1059};1060let () = callee1061.call_async(store.as_context_mut(), (arg0,))1062.instrument(span.clone())1063.await?;1064callee1065.post_return_async(store.as_context_mut())1066.instrument(span)1067.await?;1068Ok(())1069}1070pub async fn call_a2<S: wasmtime::AsContextMut>(1071&self,1072mut store: S,1073arg0: i8,1074) -> wasmtime::Result<()>1075where1076<S as wasmtime::AsContext>::Data: Send,1077{1078use tracing::Instrument;1079let span = tracing::span!(1080tracing::Level::TRACE, "wit-bindgen export", module =1081"foo:foo/integers", function = "a2",1082);1083let callee = unsafe {1084wasmtime::component::TypedFunc::<1085(i8,),1086(),1087>::new_unchecked(self.a2)1088};1089let () = callee1090.call_async(store.as_context_mut(), (arg0,))1091.instrument(span.clone())1092.await?;1093callee1094.post_return_async(store.as_context_mut())1095.instrument(span)1096.await?;1097Ok(())1098}1099pub async fn call_a3<S: wasmtime::AsContextMut>(1100&self,1101mut store: S,1102arg0: u16,1103) -> wasmtime::Result<()>1104where1105<S as wasmtime::AsContext>::Data: Send,1106{1107use tracing::Instrument;1108let span = tracing::span!(1109tracing::Level::TRACE, "wit-bindgen export", module =1110"foo:foo/integers", function = "a3",1111);1112let callee = unsafe {1113wasmtime::component::TypedFunc::<1114(u16,),1115(),1116>::new_unchecked(self.a3)1117};1118let () = callee1119.call_async(store.as_context_mut(), (arg0,))1120.instrument(span.clone())1121.await?;1122callee1123.post_return_async(store.as_context_mut())1124.instrument(span)1125.await?;1126Ok(())1127}1128pub async fn call_a4<S: wasmtime::AsContextMut>(1129&self,1130mut store: S,1131arg0: i16,1132) -> wasmtime::Result<()>1133where1134<S as wasmtime::AsContext>::Data: Send,1135{1136use tracing::Instrument;1137let span = tracing::span!(1138tracing::Level::TRACE, "wit-bindgen export", module =1139"foo:foo/integers", function = "a4",1140);1141let callee = unsafe {1142wasmtime::component::TypedFunc::<1143(i16,),1144(),1145>::new_unchecked(self.a4)1146};1147let () = callee1148.call_async(store.as_context_mut(), (arg0,))1149.instrument(span.clone())1150.await?;1151callee1152.post_return_async(store.as_context_mut())1153.instrument(span)1154.await?;1155Ok(())1156}1157pub async fn call_a5<S: wasmtime::AsContextMut>(1158&self,1159mut store: S,1160arg0: u32,1161) -> wasmtime::Result<()>1162where1163<S as wasmtime::AsContext>::Data: Send,1164{1165use tracing::Instrument;1166let span = tracing::span!(1167tracing::Level::TRACE, "wit-bindgen export", module =1168"foo:foo/integers", function = "a5",1169);1170let callee = unsafe {1171wasmtime::component::TypedFunc::<1172(u32,),1173(),1174>::new_unchecked(self.a5)1175};1176let () = callee1177.call_async(store.as_context_mut(), (arg0,))1178.instrument(span.clone())1179.await?;1180callee1181.post_return_async(store.as_context_mut())1182.instrument(span)1183.await?;1184Ok(())1185}1186pub async fn call_a6<S: wasmtime::AsContextMut>(1187&self,1188mut store: S,1189arg0: i32,1190) -> wasmtime::Result<()>1191where1192<S as wasmtime::AsContext>::Data: Send,1193{1194use tracing::Instrument;1195let span = tracing::span!(1196tracing::Level::TRACE, "wit-bindgen export", module =1197"foo:foo/integers", function = "a6",1198);1199let callee = unsafe {1200wasmtime::component::TypedFunc::<1201(i32,),1202(),1203>::new_unchecked(self.a6)1204};1205let () = callee1206.call_async(store.as_context_mut(), (arg0,))1207.instrument(span.clone())1208.await?;1209callee1210.post_return_async(store.as_context_mut())1211.instrument(span)1212.await?;1213Ok(())1214}1215pub async fn call_a7<S: wasmtime::AsContextMut>(1216&self,1217mut store: S,1218arg0: u64,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 = "a7",1227);1228let callee = unsafe {1229wasmtime::component::TypedFunc::<1230(u64,),1231(),1232>::new_unchecked(self.a7)1233};1234let () = callee1235.call_async(store.as_context_mut(), (arg0,))1236.instrument(span.clone())1237.await?;1238callee1239.post_return_async(store.as_context_mut())1240.instrument(span)1241.await?;1242Ok(())1243}1244pub async fn call_a8<S: wasmtime::AsContextMut>(1245&self,1246mut store: S,1247arg0: i64,1248) -> wasmtime::Result<()>1249where1250<S as wasmtime::AsContext>::Data: Send,1251{1252use tracing::Instrument;1253let span = tracing::span!(1254tracing::Level::TRACE, "wit-bindgen export", module =1255"foo:foo/integers", function = "a8",1256);1257let callee = unsafe {1258wasmtime::component::TypedFunc::<1259(i64,),1260(),1261>::new_unchecked(self.a8)1262};1263let () = callee1264.call_async(store.as_context_mut(), (arg0,))1265.instrument(span.clone())1266.await?;1267callee1268.post_return_async(store.as_context_mut())1269.instrument(span)1270.await?;1271Ok(())1272}1273pub async fn call_a9<S: wasmtime::AsContextMut>(1274&self,1275mut store: S,1276arg0: u8,1277arg1: i8,1278arg2: u16,1279arg3: i16,1280arg4: u32,1281arg5: i32,1282arg6: u64,1283arg7: i64,1284) -> wasmtime::Result<()>1285where1286<S as wasmtime::AsContext>::Data: Send,1287{1288use tracing::Instrument;1289let span = tracing::span!(1290tracing::Level::TRACE, "wit-bindgen export", module =1291"foo:foo/integers", function = "a9",1292);1293let callee = unsafe {1294wasmtime::component::TypedFunc::<1295(u8, i8, u16, i16, u32, i32, u64, i64),1296(),1297>::new_unchecked(self.a9)1298};1299let () = callee1300.call_async(1301store.as_context_mut(),1302(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7),1303)1304.instrument(span.clone())1305.await?;1306callee1307.post_return_async(store.as_context_mut())1308.instrument(span)1309.await?;1310Ok(())1311}1312pub async fn call_r1<S: wasmtime::AsContextMut>(1313&self,1314mut store: S,1315) -> wasmtime::Result<u8>1316where1317<S as wasmtime::AsContext>::Data: Send,1318{1319use tracing::Instrument;1320let span = tracing::span!(1321tracing::Level::TRACE, "wit-bindgen export", module =1322"foo:foo/integers", function = "r1",1323);1324let callee = unsafe {1325wasmtime::component::TypedFunc::<1326(),1327(u8,),1328>::new_unchecked(self.r1)1329};1330let (ret0,) = callee1331.call_async(store.as_context_mut(), ())1332.instrument(span.clone())1333.await?;1334callee1335.post_return_async(store.as_context_mut())1336.instrument(span)1337.await?;1338Ok(ret0)1339}1340pub async fn call_r2<S: wasmtime::AsContextMut>(1341&self,1342mut store: S,1343) -> wasmtime::Result<i8>1344where1345<S as wasmtime::AsContext>::Data: Send,1346{1347use tracing::Instrument;1348let span = tracing::span!(1349tracing::Level::TRACE, "wit-bindgen export", module =1350"foo:foo/integers", function = "r2",1351);1352let callee = unsafe {1353wasmtime::component::TypedFunc::<1354(),1355(i8,),1356>::new_unchecked(self.r2)1357};1358let (ret0,) = callee1359.call_async(store.as_context_mut(), ())1360.instrument(span.clone())1361.await?;1362callee1363.post_return_async(store.as_context_mut())1364.instrument(span)1365.await?;1366Ok(ret0)1367}1368pub async fn call_r3<S: wasmtime::AsContextMut>(1369&self,1370mut store: S,1371) -> wasmtime::Result<u16>1372where1373<S as wasmtime::AsContext>::Data: Send,1374{1375use tracing::Instrument;1376let span = tracing::span!(1377tracing::Level::TRACE, "wit-bindgen export", module =1378"foo:foo/integers", function = "r3",1379);1380let callee = unsafe {1381wasmtime::component::TypedFunc::<1382(),1383(u16,),1384>::new_unchecked(self.r3)1385};1386let (ret0,) = callee1387.call_async(store.as_context_mut(), ())1388.instrument(span.clone())1389.await?;1390callee1391.post_return_async(store.as_context_mut())1392.instrument(span)1393.await?;1394Ok(ret0)1395}1396pub async fn call_r4<S: wasmtime::AsContextMut>(1397&self,1398mut store: S,1399) -> wasmtime::Result<i16>1400where1401<S as wasmtime::AsContext>::Data: Send,1402{1403use tracing::Instrument;1404let span = tracing::span!(1405tracing::Level::TRACE, "wit-bindgen export", module =1406"foo:foo/integers", function = "r4",1407);1408let callee = unsafe {1409wasmtime::component::TypedFunc::<1410(),1411(i16,),1412>::new_unchecked(self.r4)1413};1414let (ret0,) = callee1415.call_async(store.as_context_mut(), ())1416.instrument(span.clone())1417.await?;1418callee1419.post_return_async(store.as_context_mut())1420.instrument(span)1421.await?;1422Ok(ret0)1423}1424pub async fn call_r5<S: wasmtime::AsContextMut>(1425&self,1426mut store: S,1427) -> wasmtime::Result<u32>1428where1429<S as wasmtime::AsContext>::Data: Send,1430{1431use tracing::Instrument;1432let span = tracing::span!(1433tracing::Level::TRACE, "wit-bindgen export", module =1434"foo:foo/integers", function = "r5",1435);1436let callee = unsafe {1437wasmtime::component::TypedFunc::<1438(),1439(u32,),1440>::new_unchecked(self.r5)1441};1442let (ret0,) = callee1443.call_async(store.as_context_mut(), ())1444.instrument(span.clone())1445.await?;1446callee1447.post_return_async(store.as_context_mut())1448.instrument(span)1449.await?;1450Ok(ret0)1451}1452pub async fn call_r6<S: wasmtime::AsContextMut>(1453&self,1454mut store: S,1455) -> wasmtime::Result<i32>1456where1457<S as wasmtime::AsContext>::Data: Send,1458{1459use tracing::Instrument;1460let span = tracing::span!(1461tracing::Level::TRACE, "wit-bindgen export", module =1462"foo:foo/integers", function = "r6",1463);1464let callee = unsafe {1465wasmtime::component::TypedFunc::<1466(),1467(i32,),1468>::new_unchecked(self.r6)1469};1470let (ret0,) = callee1471.call_async(store.as_context_mut(), ())1472.instrument(span.clone())1473.await?;1474callee1475.post_return_async(store.as_context_mut())1476.instrument(span)1477.await?;1478Ok(ret0)1479}1480pub async fn call_r7<S: wasmtime::AsContextMut>(1481&self,1482mut store: S,1483) -> wasmtime::Result<u64>1484where1485<S as wasmtime::AsContext>::Data: Send,1486{1487use tracing::Instrument;1488let span = tracing::span!(1489tracing::Level::TRACE, "wit-bindgen export", module =1490"foo:foo/integers", function = "r7",1491);1492let callee = unsafe {1493wasmtime::component::TypedFunc::<1494(),1495(u64,),1496>::new_unchecked(self.r7)1497};1498let (ret0,) = callee1499.call_async(store.as_context_mut(), ())1500.instrument(span.clone())1501.await?;1502callee1503.post_return_async(store.as_context_mut())1504.instrument(span)1505.await?;1506Ok(ret0)1507}1508pub async fn call_r8<S: wasmtime::AsContextMut>(1509&self,1510mut store: S,1511) -> wasmtime::Result<i64>1512where1513<S as wasmtime::AsContext>::Data: Send,1514{1515use tracing::Instrument;1516let span = tracing::span!(1517tracing::Level::TRACE, "wit-bindgen export", module =1518"foo:foo/integers", function = "r8",1519);1520let callee = unsafe {1521wasmtime::component::TypedFunc::<1522(),1523(i64,),1524>::new_unchecked(self.r8)1525};1526let (ret0,) = callee1527.call_async(store.as_context_mut(), ())1528.instrument(span.clone())1529.await?;1530callee1531.post_return_async(store.as_context_mut())1532.instrument(span)1533.await?;1534Ok(ret0)1535}1536pub async fn call_pair_ret<S: wasmtime::AsContextMut>(1537&self,1538mut store: S,1539) -> wasmtime::Result<(i64, u8)>1540where1541<S as wasmtime::AsContext>::Data: Send,1542{1543use tracing::Instrument;1544let span = tracing::span!(1545tracing::Level::TRACE, "wit-bindgen export", module =1546"foo:foo/integers", function = "pair-ret",1547);1548let callee = unsafe {1549wasmtime::component::TypedFunc::<1550(),1551((i64, u8),),1552>::new_unchecked(self.pair_ret)1553};1554let (ret0,) = callee1555.call_async(store.as_context_mut(), ())1556.instrument(span.clone())1557.await?;1558callee1559.post_return_async(store.as_context_mut())1560.instrument(span)1561.await?;1562Ok(ret0)1563}1564}1565}1566}1567}1568}156915701571