Path: blob/main/crates/component-macro/tests/expanded/conventions_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::conventions::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::conventions::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::conventions::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::conventions::HostWithStore + Send,178for<'a> D::Data<'a>: foo::foo::conventions::Host + Send,179T: 'static + Send,180{181foo::foo::conventions::add_to_linker::<T, D>(linker, host_getter)?;182Ok(())183}184pub fn foo_foo_conventions(&self) -> &exports::foo::foo::conventions::Guest {185&self.interface0186}187}188};189pub mod foo {190pub mod foo {191#[allow(clippy::all)]192pub mod conventions {193#[allow(unused_imports)]194use wasmtime::component::__internal::{anyhow, Box};195#[derive(wasmtime::component::ComponentType)]196#[derive(wasmtime::component::Lift)]197#[derive(wasmtime::component::Lower)]198#[component(record)]199#[derive(Clone, Copy)]200pub struct LudicrousSpeed {201#[component(name = "how-fast-are-you-going")]202pub how_fast_are_you_going: u32,203#[component(name = "i-am-going-extremely-slow")]204pub i_am_going_extremely_slow: u64,205}206impl core::fmt::Debug for LudicrousSpeed {207fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {208f.debug_struct("LudicrousSpeed")209.field("how-fast-are-you-going", &self.how_fast_are_you_going)210.field(211"i-am-going-extremely-slow",212&self.i_am_going_extremely_slow,213)214.finish()215}216}217const _: () = {218assert!(21916 == < LudicrousSpeed as wasmtime::component::ComponentType220>::SIZE32221);222assert!(2238 == < LudicrousSpeed as wasmtime::component::ComponentType224>::ALIGN32225);226};227pub trait HostWithStore: wasmtime::component::HasData + Send {}228impl<_T: ?Sized> HostWithStore for _T229where230_T: wasmtime::component::HasData + Send,231{}232pub trait Host: Send {233fn kebab_case(234&mut self,235) -> impl ::core::future::Future<Output = ()> + Send;236fn foo(237&mut self,238x: LudicrousSpeed,239) -> impl ::core::future::Future<Output = ()> + Send;240fn function_with_dashes(241&mut self,242) -> impl ::core::future::Future<Output = ()> + Send;243fn function_with_no_weird_characters(244&mut self,245) -> impl ::core::future::Future<Output = ()> + Send;246fn apple(&mut self) -> impl ::core::future::Future<Output = ()> + Send;247fn apple_pear(248&mut self,249) -> impl ::core::future::Future<Output = ()> + Send;250fn apple_pear_grape(251&mut self,252) -> impl ::core::future::Future<Output = ()> + Send;253fn a0(&mut self) -> impl ::core::future::Future<Output = ()> + Send;254/// Comment out identifiers that collide when mapped to snake_case, for now; see255/// https://github.com/WebAssembly/component-model/issues/118256/// APPLE: func()257/// APPLE-pear-GRAPE: func()258/// apple-PEAR-grape: func()259fn is_xml(&mut self) -> impl ::core::future::Future<Output = ()> + Send;260fn explicit(261&mut self,262) -> impl ::core::future::Future<Output = ()> + Send;263fn explicit_kebab(264&mut self,265) -> impl ::core::future::Future<Output = ()> + Send;266/// Identifiers with the same name as keywords are quoted.267fn bool(&mut self) -> impl ::core::future::Future<Output = ()> + Send;268}269impl<_T: Host + ?Sized + Send> Host for &mut _T {270fn kebab_case(271&mut self,272) -> impl ::core::future::Future<Output = ()> + Send {273async move { Host::kebab_case(*self).await }274}275fn foo(276&mut self,277x: LudicrousSpeed,278) -> impl ::core::future::Future<Output = ()> + Send {279async move { Host::foo(*self, x).await }280}281fn function_with_dashes(282&mut self,283) -> impl ::core::future::Future<Output = ()> + Send {284async move { Host::function_with_dashes(*self).await }285}286fn function_with_no_weird_characters(287&mut self,288) -> impl ::core::future::Future<Output = ()> + Send {289async move { Host::function_with_no_weird_characters(*self).await }290}291fn apple(&mut self) -> impl ::core::future::Future<Output = ()> + Send {292async move { Host::apple(*self).await }293}294fn apple_pear(295&mut self,296) -> impl ::core::future::Future<Output = ()> + Send {297async move { Host::apple_pear(*self).await }298}299fn apple_pear_grape(300&mut self,301) -> impl ::core::future::Future<Output = ()> + Send {302async move { Host::apple_pear_grape(*self).await }303}304fn a0(&mut self) -> impl ::core::future::Future<Output = ()> + Send {305async move { Host::a0(*self).await }306}307/// Comment out identifiers that collide when mapped to snake_case, for now; see308/// https://github.com/WebAssembly/component-model/issues/118309/// APPLE: func()310/// APPLE-pear-GRAPE: func()311/// apple-PEAR-grape: func()312fn is_xml(&mut self) -> impl ::core::future::Future<Output = ()> + Send {313async move { Host::is_xml(*self).await }314}315fn explicit(316&mut self,317) -> impl ::core::future::Future<Output = ()> + Send {318async move { Host::explicit(*self).await }319}320fn explicit_kebab(321&mut self,322) -> impl ::core::future::Future<Output = ()> + Send {323async move { Host::explicit_kebab(*self).await }324}325/// Identifiers with the same name as keywords are quoted.326fn bool(&mut self) -> impl ::core::future::Future<Output = ()> + Send {327async move { Host::bool(*self).await }328}329}330pub fn add_to_linker<T, D>(331linker: &mut wasmtime::component::Linker<T>,332host_getter: fn(&mut T) -> D::Data<'_>,333) -> wasmtime::Result<()>334where335D: HostWithStore,336for<'a> D::Data<'a>: Host,337T: 'static + Send,338{339let mut inst = linker.instance("foo:foo/conventions")?;340inst.func_wrap_async(341"kebab-case",342move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {343use tracing::Instrument;344let span = tracing::span!(345tracing::Level::TRACE, "wit-bindgen import", module =346"conventions", function = "kebab-case",347);348wasmtime::component::__internal::Box::new(349async move {350tracing::event!(tracing::Level::TRACE, "call");351let host = &mut host_getter(caller.data_mut());352let r = Host::kebab_case(host).await;353tracing::event!(354tracing::Level::TRACE, result = tracing::field::debug(& r),355"return"356);357Ok(r)358}359.instrument(span),360)361},362)?;363inst.func_wrap_async(364"foo",365move |366mut caller: wasmtime::StoreContextMut<'_, T>,367(arg0,): (LudicrousSpeed,)|368{369use tracing::Instrument;370let span = tracing::span!(371tracing::Level::TRACE, "wit-bindgen import", module =372"conventions", function = "foo",373);374wasmtime::component::__internal::Box::new(375async move {376tracing::event!(377tracing::Level::TRACE, x = tracing::field::debug(& arg0),378"call"379);380let host = &mut host_getter(caller.data_mut());381let r = Host::foo(host, arg0).await;382tracing::event!(383tracing::Level::TRACE, result = tracing::field::debug(& r),384"return"385);386Ok(r)387}388.instrument(span),389)390},391)?;392inst.func_wrap_async(393"function-with-dashes",394move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {395use tracing::Instrument;396let span = tracing::span!(397tracing::Level::TRACE, "wit-bindgen import", module =398"conventions", function = "function-with-dashes",399);400wasmtime::component::__internal::Box::new(401async move {402tracing::event!(tracing::Level::TRACE, "call");403let host = &mut host_getter(caller.data_mut());404let r = Host::function_with_dashes(host).await;405tracing::event!(406tracing::Level::TRACE, result = tracing::field::debug(& r),407"return"408);409Ok(r)410}411.instrument(span),412)413},414)?;415inst.func_wrap_async(416"function-with-no-weird-characters",417move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {418use tracing::Instrument;419let span = tracing::span!(420tracing::Level::TRACE, "wit-bindgen import", module =421"conventions", function =422"function-with-no-weird-characters",423);424wasmtime::component::__internal::Box::new(425async move {426tracing::event!(tracing::Level::TRACE, "call");427let host = &mut host_getter(caller.data_mut());428let r = Host::function_with_no_weird_characters(host).await;429tracing::event!(430tracing::Level::TRACE, result = tracing::field::debug(& r),431"return"432);433Ok(r)434}435.instrument(span),436)437},438)?;439inst.func_wrap_async(440"apple",441move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {442use tracing::Instrument;443let span = tracing::span!(444tracing::Level::TRACE, "wit-bindgen import", module =445"conventions", function = "apple",446);447wasmtime::component::__internal::Box::new(448async move {449tracing::event!(tracing::Level::TRACE, "call");450let host = &mut host_getter(caller.data_mut());451let r = Host::apple(host).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"apple-pear",464move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {465use tracing::Instrument;466let span = tracing::span!(467tracing::Level::TRACE, "wit-bindgen import", module =468"conventions", function = "apple-pear",469);470wasmtime::component::__internal::Box::new(471async move {472tracing::event!(tracing::Level::TRACE, "call");473let host = &mut host_getter(caller.data_mut());474let r = Host::apple_pear(host).await;475tracing::event!(476tracing::Level::TRACE, result = tracing::field::debug(& r),477"return"478);479Ok(r)480}481.instrument(span),482)483},484)?;485inst.func_wrap_async(486"apple-pear-grape",487move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {488use tracing::Instrument;489let span = tracing::span!(490tracing::Level::TRACE, "wit-bindgen import", module =491"conventions", function = "apple-pear-grape",492);493wasmtime::component::__internal::Box::new(494async move {495tracing::event!(tracing::Level::TRACE, "call");496let host = &mut host_getter(caller.data_mut());497let r = Host::apple_pear_grape(host).await;498tracing::event!(499tracing::Level::TRACE, result = tracing::field::debug(& r),500"return"501);502Ok(r)503}504.instrument(span),505)506},507)?;508inst.func_wrap_async(509"a0",510move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {511use tracing::Instrument;512let span = tracing::span!(513tracing::Level::TRACE, "wit-bindgen import", module =514"conventions", function = "a0",515);516wasmtime::component::__internal::Box::new(517async move {518tracing::event!(tracing::Level::TRACE, "call");519let host = &mut host_getter(caller.data_mut());520let r = Host::a0(host).await;521tracing::event!(522tracing::Level::TRACE, result = tracing::field::debug(& r),523"return"524);525Ok(r)526}527.instrument(span),528)529},530)?;531inst.func_wrap_async(532"is-XML",533move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {534use tracing::Instrument;535let span = tracing::span!(536tracing::Level::TRACE, "wit-bindgen import", module =537"conventions", function = "is-XML",538);539wasmtime::component::__internal::Box::new(540async move {541tracing::event!(tracing::Level::TRACE, "call");542let host = &mut host_getter(caller.data_mut());543let r = Host::is_xml(host).await;544tracing::event!(545tracing::Level::TRACE, result = tracing::field::debug(& r),546"return"547);548Ok(r)549}550.instrument(span),551)552},553)?;554inst.func_wrap_async(555"explicit",556move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {557use tracing::Instrument;558let span = tracing::span!(559tracing::Level::TRACE, "wit-bindgen import", module =560"conventions", function = "explicit",561);562wasmtime::component::__internal::Box::new(563async move {564tracing::event!(tracing::Level::TRACE, "call");565let host = &mut host_getter(caller.data_mut());566let r = Host::explicit(host).await;567tracing::event!(568tracing::Level::TRACE, result = tracing::field::debug(& r),569"return"570);571Ok(r)572}573.instrument(span),574)575},576)?;577inst.func_wrap_async(578"explicit-kebab",579move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {580use tracing::Instrument;581let span = tracing::span!(582tracing::Level::TRACE, "wit-bindgen import", module =583"conventions", function = "explicit-kebab",584);585wasmtime::component::__internal::Box::new(586async move {587tracing::event!(tracing::Level::TRACE, "call");588let host = &mut host_getter(caller.data_mut());589let r = Host::explicit_kebab(host).await;590tracing::event!(591tracing::Level::TRACE, result = tracing::field::debug(& r),592"return"593);594Ok(r)595}596.instrument(span),597)598},599)?;600inst.func_wrap_async(601"bool",602move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {603use tracing::Instrument;604let span = tracing::span!(605tracing::Level::TRACE, "wit-bindgen import", module =606"conventions", function = "bool",607);608wasmtime::component::__internal::Box::new(609async move {610tracing::event!(tracing::Level::TRACE, "call");611let host = &mut host_getter(caller.data_mut());612let r = Host::bool(host).await;613tracing::event!(614tracing::Level::TRACE, result = tracing::field::debug(& r),615"return"616);617Ok(r)618}619.instrument(span),620)621},622)?;623Ok(())624}625}626}627}628pub mod exports {629pub mod foo {630pub mod foo {631#[allow(clippy::all)]632pub mod conventions {633#[allow(unused_imports)]634use wasmtime::component::__internal::{anyhow, Box};635#[derive(wasmtime::component::ComponentType)]636#[derive(wasmtime::component::Lift)]637#[derive(wasmtime::component::Lower)]638#[component(record)]639#[derive(Clone, Copy)]640pub struct LudicrousSpeed {641#[component(name = "how-fast-are-you-going")]642pub how_fast_are_you_going: u32,643#[component(name = "i-am-going-extremely-slow")]644pub i_am_going_extremely_slow: u64,645}646impl core::fmt::Debug for LudicrousSpeed {647fn fmt(648&self,649f: &mut core::fmt::Formatter<'_>,650) -> core::fmt::Result {651f.debug_struct("LudicrousSpeed")652.field(653"how-fast-are-you-going",654&self.how_fast_are_you_going,655)656.field(657"i-am-going-extremely-slow",658&self.i_am_going_extremely_slow,659)660.finish()661}662}663const _: () = {664assert!(66516 == < LudicrousSpeed as wasmtime::component::ComponentType666>::SIZE32667);668assert!(6698 == < LudicrousSpeed as wasmtime::component::ComponentType670>::ALIGN32671);672};673pub struct Guest {674kebab_case: wasmtime::component::Func,675foo: wasmtime::component::Func,676function_with_dashes: wasmtime::component::Func,677function_with_no_weird_characters: wasmtime::component::Func,678apple: wasmtime::component::Func,679apple_pear: wasmtime::component::Func,680apple_pear_grape: wasmtime::component::Func,681a0: wasmtime::component::Func,682is_xml: wasmtime::component::Func,683explicit: wasmtime::component::Func,684explicit_kebab: wasmtime::component::Func,685bool: wasmtime::component::Func,686}687#[derive(Clone)]688pub struct GuestIndices {689kebab_case: wasmtime::component::ComponentExportIndex,690foo: wasmtime::component::ComponentExportIndex,691function_with_dashes: wasmtime::component::ComponentExportIndex,692function_with_no_weird_characters: wasmtime::component::ComponentExportIndex,693apple: wasmtime::component::ComponentExportIndex,694apple_pear: wasmtime::component::ComponentExportIndex,695apple_pear_grape: wasmtime::component::ComponentExportIndex,696a0: wasmtime::component::ComponentExportIndex,697is_xml: wasmtime::component::ComponentExportIndex,698explicit: wasmtime::component::ComponentExportIndex,699explicit_kebab: wasmtime::component::ComponentExportIndex,700bool: wasmtime::component::ComponentExportIndex,701}702impl GuestIndices {703/// Constructor for [`GuestIndices`] which takes a704/// [`Component`](wasmtime::component::Component) as input and can be executed705/// before instantiation.706///707/// This constructor can be used to front-load string lookups to find exports708/// within a component.709pub fn new<_T>(710_instance_pre: &wasmtime::component::InstancePre<_T>,711) -> wasmtime::Result<GuestIndices> {712let instance = _instance_pre713.component()714.get_export_index(None, "foo:foo/conventions")715.ok_or_else(|| {716anyhow::anyhow!(717"no exported instance named `foo:foo/conventions`"718)719})?;720let mut lookup = move |name| {721_instance_pre722.component()723.get_export_index(Some(&instance), name)724.ok_or_else(|| {725anyhow::anyhow!(726"instance export `foo:foo/conventions` does \727not have export `{name}`"728)729})730};731let _ = &mut lookup;732let kebab_case = lookup("kebab-case")?;733let foo = lookup("foo")?;734let function_with_dashes = lookup("function-with-dashes")?;735let function_with_no_weird_characters = lookup(736"function-with-no-weird-characters",737)?;738let apple = lookup("apple")?;739let apple_pear = lookup("apple-pear")?;740let apple_pear_grape = lookup("apple-pear-grape")?;741let a0 = lookup("a0")?;742let is_xml = lookup("is-XML")?;743let explicit = lookup("explicit")?;744let explicit_kebab = lookup("explicit-kebab")?;745let bool = lookup("bool")?;746Ok(GuestIndices {747kebab_case,748foo,749function_with_dashes,750function_with_no_weird_characters,751apple,752apple_pear,753apple_pear_grape,754a0,755is_xml,756explicit,757explicit_kebab,758bool,759})760}761pub fn load(762&self,763mut store: impl wasmtime::AsContextMut,764instance: &wasmtime::component::Instance,765) -> wasmtime::Result<Guest> {766let _instance = instance;767let _instance_pre = _instance.instance_pre(&store);768let _instance_type = _instance_pre.instance_type();769let mut store = store.as_context_mut();770let _ = &mut store;771let kebab_case = *_instance772.get_typed_func::<(), ()>(&mut store, &self.kebab_case)?773.func();774let foo = *_instance775.get_typed_func::<776(LudicrousSpeed,),777(),778>(&mut store, &self.foo)?779.func();780let function_with_dashes = *_instance781.get_typed_func::<782(),783(),784>(&mut store, &self.function_with_dashes)?785.func();786let function_with_no_weird_characters = *_instance787.get_typed_func::<788(),789(),790>(&mut store, &self.function_with_no_weird_characters)?791.func();792let apple = *_instance793.get_typed_func::<(), ()>(&mut store, &self.apple)?794.func();795let apple_pear = *_instance796.get_typed_func::<(), ()>(&mut store, &self.apple_pear)?797.func();798let apple_pear_grape = *_instance799.get_typed_func::<800(),801(),802>(&mut store, &self.apple_pear_grape)?803.func();804let a0 = *_instance805.get_typed_func::<(), ()>(&mut store, &self.a0)?806.func();807let is_xml = *_instance808.get_typed_func::<(), ()>(&mut store, &self.is_xml)?809.func();810let explicit = *_instance811.get_typed_func::<(), ()>(&mut store, &self.explicit)?812.func();813let explicit_kebab = *_instance814.get_typed_func::<(), ()>(&mut store, &self.explicit_kebab)?815.func();816let bool = *_instance817.get_typed_func::<(), ()>(&mut store, &self.bool)?818.func();819Ok(Guest {820kebab_case,821foo,822function_with_dashes,823function_with_no_weird_characters,824apple,825apple_pear,826apple_pear_grape,827a0,828is_xml,829explicit,830explicit_kebab,831bool,832})833}834}835impl Guest {836pub async fn call_kebab_case<S: wasmtime::AsContextMut>(837&self,838mut store: S,839) -> wasmtime::Result<()>840where841<S as wasmtime::AsContext>::Data: Send,842{843use tracing::Instrument;844let span = tracing::span!(845tracing::Level::TRACE, "wit-bindgen export", module =846"foo:foo/conventions", function = "kebab-case",847);848let callee = unsafe {849wasmtime::component::TypedFunc::<850(),851(),852>::new_unchecked(self.kebab_case)853};854let () = callee855.call_async(store.as_context_mut(), ())856.instrument(span.clone())857.await?;858callee859.post_return_async(store.as_context_mut())860.instrument(span)861.await?;862Ok(())863}864pub async fn call_foo<S: wasmtime::AsContextMut>(865&self,866mut store: S,867arg0: LudicrousSpeed,868) -> wasmtime::Result<()>869where870<S as wasmtime::AsContext>::Data: Send,871{872use tracing::Instrument;873let span = tracing::span!(874tracing::Level::TRACE, "wit-bindgen export", module =875"foo:foo/conventions", function = "foo",876);877let callee = unsafe {878wasmtime::component::TypedFunc::<879(LudicrousSpeed,),880(),881>::new_unchecked(self.foo)882};883let () = callee884.call_async(store.as_context_mut(), (arg0,))885.instrument(span.clone())886.await?;887callee888.post_return_async(store.as_context_mut())889.instrument(span)890.await?;891Ok(())892}893pub async fn call_function_with_dashes<S: wasmtime::AsContextMut>(894&self,895mut store: S,896) -> wasmtime::Result<()>897where898<S as wasmtime::AsContext>::Data: Send,899{900use tracing::Instrument;901let span = tracing::span!(902tracing::Level::TRACE, "wit-bindgen export", module =903"foo:foo/conventions", function = "function-with-dashes",904);905let callee = unsafe {906wasmtime::component::TypedFunc::<907(),908(),909>::new_unchecked(self.function_with_dashes)910};911let () = callee912.call_async(store.as_context_mut(), ())913.instrument(span.clone())914.await?;915callee916.post_return_async(store.as_context_mut())917.instrument(span)918.await?;919Ok(())920}921pub async fn call_function_with_no_weird_characters<922S: wasmtime::AsContextMut,923>(&self, mut store: S) -> wasmtime::Result<()>924where925<S as wasmtime::AsContext>::Data: Send,926{927use tracing::Instrument;928let span = tracing::span!(929tracing::Level::TRACE, "wit-bindgen export", module =930"foo:foo/conventions", function =931"function-with-no-weird-characters",932);933let callee = unsafe {934wasmtime::component::TypedFunc::<935(),936(),937>::new_unchecked(self.function_with_no_weird_characters)938};939let () = callee940.call_async(store.as_context_mut(), ())941.instrument(span.clone())942.await?;943callee944.post_return_async(store.as_context_mut())945.instrument(span)946.await?;947Ok(())948}949pub async fn call_apple<S: wasmtime::AsContextMut>(950&self,951mut store: S,952) -> wasmtime::Result<()>953where954<S as wasmtime::AsContext>::Data: Send,955{956use tracing::Instrument;957let span = tracing::span!(958tracing::Level::TRACE, "wit-bindgen export", module =959"foo:foo/conventions", function = "apple",960);961let callee = unsafe {962wasmtime::component::TypedFunc::<963(),964(),965>::new_unchecked(self.apple)966};967let () = callee968.call_async(store.as_context_mut(), ())969.instrument(span.clone())970.await?;971callee972.post_return_async(store.as_context_mut())973.instrument(span)974.await?;975Ok(())976}977pub async fn call_apple_pear<S: wasmtime::AsContextMut>(978&self,979mut store: S,980) -> wasmtime::Result<()>981where982<S as wasmtime::AsContext>::Data: Send,983{984use tracing::Instrument;985let span = tracing::span!(986tracing::Level::TRACE, "wit-bindgen export", module =987"foo:foo/conventions", function = "apple-pear",988);989let callee = unsafe {990wasmtime::component::TypedFunc::<991(),992(),993>::new_unchecked(self.apple_pear)994};995let () = callee996.call_async(store.as_context_mut(), ())997.instrument(span.clone())998.await?;999callee1000.post_return_async(store.as_context_mut())1001.instrument(span)1002.await?;1003Ok(())1004}1005pub async fn call_apple_pear_grape<S: wasmtime::AsContextMut>(1006&self,1007mut store: S,1008) -> wasmtime::Result<()>1009where1010<S as wasmtime::AsContext>::Data: Send,1011{1012use tracing::Instrument;1013let span = tracing::span!(1014tracing::Level::TRACE, "wit-bindgen export", module =1015"foo:foo/conventions", function = "apple-pear-grape",1016);1017let callee = unsafe {1018wasmtime::component::TypedFunc::<1019(),1020(),1021>::new_unchecked(self.apple_pear_grape)1022};1023let () = callee1024.call_async(store.as_context_mut(), ())1025.instrument(span.clone())1026.await?;1027callee1028.post_return_async(store.as_context_mut())1029.instrument(span)1030.await?;1031Ok(())1032}1033pub async fn call_a0<S: wasmtime::AsContextMut>(1034&self,1035mut store: S,1036) -> wasmtime::Result<()>1037where1038<S as wasmtime::AsContext>::Data: Send,1039{1040use tracing::Instrument;1041let span = tracing::span!(1042tracing::Level::TRACE, "wit-bindgen export", module =1043"foo:foo/conventions", function = "a0",1044);1045let callee = unsafe {1046wasmtime::component::TypedFunc::<1047(),1048(),1049>::new_unchecked(self.a0)1050};1051let () = callee1052.call_async(store.as_context_mut(), ())1053.instrument(span.clone())1054.await?;1055callee1056.post_return_async(store.as_context_mut())1057.instrument(span)1058.await?;1059Ok(())1060}1061/// Comment out identifiers that collide when mapped to snake_case, for now; see1062/// https://github.com/WebAssembly/component-model/issues/1181063/// APPLE: func()1064/// APPLE-pear-GRAPE: func()1065/// apple-PEAR-grape: func()1066pub async fn call_is_xml<S: wasmtime::AsContextMut>(1067&self,1068mut store: S,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/conventions", function = "is-XML",1077);1078let callee = unsafe {1079wasmtime::component::TypedFunc::<1080(),1081(),1082>::new_unchecked(self.is_xml)1083};1084let () = callee1085.call_async(store.as_context_mut(), ())1086.instrument(span.clone())1087.await?;1088callee1089.post_return_async(store.as_context_mut())1090.instrument(span)1091.await?;1092Ok(())1093}1094pub async fn call_explicit<S: wasmtime::AsContextMut>(1095&self,1096mut store: S,1097) -> wasmtime::Result<()>1098where1099<S as wasmtime::AsContext>::Data: Send,1100{1101use tracing::Instrument;1102let span = tracing::span!(1103tracing::Level::TRACE, "wit-bindgen export", module =1104"foo:foo/conventions", function = "explicit",1105);1106let callee = unsafe {1107wasmtime::component::TypedFunc::<1108(),1109(),1110>::new_unchecked(self.explicit)1111};1112let () = callee1113.call_async(store.as_context_mut(), ())1114.instrument(span.clone())1115.await?;1116callee1117.post_return_async(store.as_context_mut())1118.instrument(span)1119.await?;1120Ok(())1121}1122pub async fn call_explicit_kebab<S: wasmtime::AsContextMut>(1123&self,1124mut store: S,1125) -> wasmtime::Result<()>1126where1127<S as wasmtime::AsContext>::Data: Send,1128{1129use tracing::Instrument;1130let span = tracing::span!(1131tracing::Level::TRACE, "wit-bindgen export", module =1132"foo:foo/conventions", function = "explicit-kebab",1133);1134let callee = unsafe {1135wasmtime::component::TypedFunc::<1136(),1137(),1138>::new_unchecked(self.explicit_kebab)1139};1140let () = callee1141.call_async(store.as_context_mut(), ())1142.instrument(span.clone())1143.await?;1144callee1145.post_return_async(store.as_context_mut())1146.instrument(span)1147.await?;1148Ok(())1149}1150/// Identifiers with the same name as keywords are quoted.1151pub async fn call_bool<S: wasmtime::AsContextMut>(1152&self,1153mut store: S,1154) -> wasmtime::Result<()>1155where1156<S as wasmtime::AsContext>::Data: Send,1157{1158use tracing::Instrument;1159let span = tracing::span!(1160tracing::Level::TRACE, "wit-bindgen export", module =1161"foo:foo/conventions", function = "bool",1162);1163let callee = unsafe {1164wasmtime::component::TypedFunc::<1165(),1166(),1167>::new_unchecked(self.bool)1168};1169let () = callee1170.call_async(store.as_context_mut(), ())1171.instrument(span.clone())1172.await?;1173callee1174.post_return_async(store.as_context_mut())1175.instrument(span)1176.await?;1177Ok(())1178}1179}1180}1181}1182}1183}118411851186