Path: blob/main/crates/component-macro/tests/expanded/flags_tracing_async.rs
1692 views
/// Auto-generated bindings for a pre-instantiated version of a1/// component which implements the world `the-flags`.2///3/// This structure is created through [`TheFlagsPre::new`] which4/// takes a [`InstancePre`](wasmtime::component::InstancePre) that5/// has been created through a [`Linker`](wasmtime::component::Linker).6///7/// For more information see [`TheFlags`] as well.8pub struct TheFlagsPre<T: 'static> {9instance_pre: wasmtime::component::InstancePre<T>,10indices: TheFlagsIndices,11}12impl<T: 'static> Clone for TheFlagsPre<T> {13fn clone(&self) -> Self {14Self {15instance_pre: self.instance_pre.clone(),16indices: self.indices.clone(),17}18}19}20impl<_T: 'static> TheFlagsPre<_T> {21/// Creates a new copy of `TheFlagsPre` 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 = TheFlagsIndices::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 [`TheFlags`] 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<TheFlags> {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> TheFlagsPre<_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<TheFlags> {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-flags`.67///68/// This is an implementation detail of [`TheFlagsPre`] and can69/// be constructed if needed as well.70///71/// For more information see [`TheFlags`] as well.72#[derive(Clone)]73pub struct TheFlagsIndices {74interface0: exports::foo::foo::flegs::GuestIndices,75}76/// Auto-generated bindings for an instance a component which77/// implements the world `the-flags`.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/// [`TheFlags::instantiate`] which only needs a84/// [`Store`], [`Component`], and [`Linker`].85///86/// * Alternatively you can create a [`TheFlagsPre`] ahead of87/// time with a [`Component`] to front-load string lookups88/// of exports once instead of per-instantiation. This89/// method then uses [`TheFlagsPre::instantiate`] to90/// create a [`TheFlags`].91///92/// * If you've instantiated the instance yourself already93/// then you can use [`TheFlags::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 TheFlags {102interface0: exports::foo::foo::flegs::Guest,103}104const _: () = {105#[allow(unused_imports)]106use wasmtime::component::__internal::anyhow;107impl TheFlagsIndices {108/// Creates a new copy of `TheFlagsIndices` 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::flegs::GuestIndices::new(_instance_pre)?;119Ok(TheFlagsIndices { interface0 })120}121/// Uses the indices stored in `self` to load an instance122/// of [`TheFlags`] 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<TheFlags> {131let _ = &mut store;132let _instance = instance;133let interface0 = self.interface0.load(&mut store, &_instance)?;134Ok(TheFlags { interface0 })135}136}137impl TheFlags {138/// Convenience wrapper around [`TheFlagsPre::new`] and139/// [`TheFlagsPre::instantiate`].140pub fn instantiate<_T>(141store: impl wasmtime::AsContextMut<Data = _T>,142component: &wasmtime::component::Component,143linker: &wasmtime::component::Linker<_T>,144) -> wasmtime::Result<TheFlags> {145let pre = linker.instantiate_pre(component)?;146TheFlagsPre::new(pre)?.instantiate(store)147}148/// Convenience wrapper around [`TheFlagsIndices::new`] and149/// [`TheFlagsIndices::load`].150pub fn new(151mut store: impl wasmtime::AsContextMut,152instance: &wasmtime::component::Instance,153) -> wasmtime::Result<TheFlags> {154let indices = TheFlagsIndices::new(&instance.instance_pre(&store))?;155indices.load(&mut store, instance)156}157/// Convenience wrapper around [`TheFlagsPre::new`] and158/// [`TheFlagsPre::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<TheFlags>164where165_T: Send,166{167let pre = linker.instantiate_pre(component)?;168TheFlagsPre::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::flegs::HostWithStore + Send,176for<'a> D::Data<'a>: foo::foo::flegs::Host + Send,177T: 'static + Send,178{179foo::foo::flegs::add_to_linker::<T, D>(linker, host_getter)?;180Ok(())181}182pub fn foo_foo_flegs(&self) -> &exports::foo::foo::flegs::Guest {183&self.interface0184}185}186};187pub mod foo {188pub mod foo {189#[allow(clippy::all)]190pub mod flegs {191#[allow(unused_imports)]192use wasmtime::component::__internal::{anyhow, Box};193wasmtime::component::flags!(Flag1 { #[component(name = "b0")] const B0; });194const _: () = {195assert!(1 == < Flag1 as wasmtime::component::ComponentType >::SIZE32);196assert!(1 == < Flag1 as wasmtime::component::ComponentType >::ALIGN32);197};198wasmtime::component::flags!(199Flag2 { #[component(name = "b0")] const B0; #[component(name = "b1")]200const B1; }201);202const _: () = {203assert!(1 == < Flag2 as wasmtime::component::ComponentType >::SIZE32);204assert!(1 == < Flag2 as wasmtime::component::ComponentType >::ALIGN32);205};206wasmtime::component::flags!(207Flag4 { #[component(name = "b0")] const B0; #[component(name = "b1")]208const B1; #[component(name = "b2")] const B2; #[component(name = "b3")]209const B3; }210);211const _: () = {212assert!(1 == < Flag4 as wasmtime::component::ComponentType >::SIZE32);213assert!(1 == < Flag4 as wasmtime::component::ComponentType >::ALIGN32);214};215wasmtime::component::flags!(216Flag8 { #[component(name = "b0")] const B0; #[component(name = "b1")]217const B1; #[component(name = "b2")] const B2; #[component(name = "b3")]218const B3; #[component(name = "b4")] const B4; #[component(name = "b5")]219const B5; #[component(name = "b6")] const B6; #[component(name = "b7")]220const B7; }221);222const _: () = {223assert!(1 == < Flag8 as wasmtime::component::ComponentType >::SIZE32);224assert!(1 == < Flag8 as wasmtime::component::ComponentType >::ALIGN32);225};226wasmtime::component::flags!(227Flag16 { #[component(name = "b0")] const B0; #[component(name = "b1")]228const B1; #[component(name = "b2")] const B2; #[component(name = "b3")]229const B3; #[component(name = "b4")] const B4; #[component(name = "b5")]230const B5; #[component(name = "b6")] const B6; #[component(name = "b7")]231const B7; #[component(name = "b8")] const B8; #[component(name = "b9")]232const B9; #[component(name = "b10")] const B10; #[component(name =233"b11")] const B11; #[component(name = "b12")] const B12; #[component(name234= "b13")] const B13; #[component(name = "b14")] const B14;235#[component(name = "b15")] const B15; }236);237const _: () = {238assert!(2 == < Flag16 as wasmtime::component::ComponentType >::SIZE32);239assert!(2 == < Flag16 as wasmtime::component::ComponentType >::ALIGN32);240};241wasmtime::component::flags!(242Flag32 { #[component(name = "b0")] const B0; #[component(name = "b1")]243const B1; #[component(name = "b2")] const B2; #[component(name = "b3")]244const B3; #[component(name = "b4")] const B4; #[component(name = "b5")]245const B5; #[component(name = "b6")] const B6; #[component(name = "b7")]246const B7; #[component(name = "b8")] const B8; #[component(name = "b9")]247const B9; #[component(name = "b10")] const B10; #[component(name =248"b11")] const B11; #[component(name = "b12")] const B12; #[component(name249= "b13")] const B13; #[component(name = "b14")] const B14;250#[component(name = "b15")] const B15; #[component(name = "b16")] const251B16; #[component(name = "b17")] const B17; #[component(name = "b18")]252const B18; #[component(name = "b19")] const B19; #[component(name =253"b20")] const B20; #[component(name = "b21")] const B21; #[component(name254= "b22")] const B22; #[component(name = "b23")] const B23;255#[component(name = "b24")] const B24; #[component(name = "b25")] const256B25; #[component(name = "b26")] const B26; #[component(name = "b27")]257const B27; #[component(name = "b28")] const B28; #[component(name =258"b29")] const B29; #[component(name = "b30")] const B30; #[component(name259= "b31")] const B31; }260);261const _: () = {262assert!(4 == < Flag32 as wasmtime::component::ComponentType >::SIZE32);263assert!(4 == < Flag32 as wasmtime::component::ComponentType >::ALIGN32);264};265wasmtime::component::flags!(266Flag64 { #[component(name = "b0")] const B0; #[component(name = "b1")]267const B1; #[component(name = "b2")] const B2; #[component(name = "b3")]268const B3; #[component(name = "b4")] const B4; #[component(name = "b5")]269const B5; #[component(name = "b6")] const B6; #[component(name = "b7")]270const B7; #[component(name = "b8")] const B8; #[component(name = "b9")]271const B9; #[component(name = "b10")] const B10; #[component(name =272"b11")] const B11; #[component(name = "b12")] const B12; #[component(name273= "b13")] const B13; #[component(name = "b14")] const B14;274#[component(name = "b15")] const B15; #[component(name = "b16")] const275B16; #[component(name = "b17")] const B17; #[component(name = "b18")]276const B18; #[component(name = "b19")] const B19; #[component(name =277"b20")] const B20; #[component(name = "b21")] const B21; #[component(name278= "b22")] const B22; #[component(name = "b23")] const B23;279#[component(name = "b24")] const B24; #[component(name = "b25")] const280B25; #[component(name = "b26")] const B26; #[component(name = "b27")]281const B27; #[component(name = "b28")] const B28; #[component(name =282"b29")] const B29; #[component(name = "b30")] const B30; #[component(name283= "b31")] const B31; #[component(name = "b32")] const B32;284#[component(name = "b33")] const B33; #[component(name = "b34")] const285B34; #[component(name = "b35")] const B35; #[component(name = "b36")]286const B36; #[component(name = "b37")] const B37; #[component(name =287"b38")] const B38; #[component(name = "b39")] const B39; #[component(name288= "b40")] const B40; #[component(name = "b41")] const B41;289#[component(name = "b42")] const B42; #[component(name = "b43")] const290B43; #[component(name = "b44")] const B44; #[component(name = "b45")]291const B45; #[component(name = "b46")] const B46; #[component(name =292"b47")] const B47; #[component(name = "b48")] const B48; #[component(name293= "b49")] const B49; #[component(name = "b50")] const B50;294#[component(name = "b51")] const B51; #[component(name = "b52")] const295B52; #[component(name = "b53")] const B53; #[component(name = "b54")]296const B54; #[component(name = "b55")] const B55; #[component(name =297"b56")] const B56; #[component(name = "b57")] const B57; #[component(name298= "b58")] const B58; #[component(name = "b59")] const B59;299#[component(name = "b60")] const B60; #[component(name = "b61")] const300B61; #[component(name = "b62")] const B62; #[component(name = "b63")]301const B63; }302);303const _: () = {304assert!(8 == < Flag64 as wasmtime::component::ComponentType >::SIZE32);305assert!(4 == < Flag64 as wasmtime::component::ComponentType >::ALIGN32);306};307pub trait HostWithStore: wasmtime::component::HasData + Send {}308impl<_T: ?Sized> HostWithStore for _T309where310_T: wasmtime::component::HasData + Send,311{}312pub trait Host: Send {313fn roundtrip_flag1(314&mut self,315x: Flag1,316) -> impl ::core::future::Future<Output = Flag1> + Send;317fn roundtrip_flag2(318&mut self,319x: Flag2,320) -> impl ::core::future::Future<Output = Flag2> + Send;321fn roundtrip_flag4(322&mut self,323x: Flag4,324) -> impl ::core::future::Future<Output = Flag4> + Send;325fn roundtrip_flag8(326&mut self,327x: Flag8,328) -> impl ::core::future::Future<Output = Flag8> + Send;329fn roundtrip_flag16(330&mut self,331x: Flag16,332) -> impl ::core::future::Future<Output = Flag16> + Send;333fn roundtrip_flag32(334&mut self,335x: Flag32,336) -> impl ::core::future::Future<Output = Flag32> + Send;337fn roundtrip_flag64(338&mut self,339x: Flag64,340) -> impl ::core::future::Future<Output = Flag64> + Send;341}342impl<_T: Host + ?Sized + Send> Host for &mut _T {343fn roundtrip_flag1(344&mut self,345x: Flag1,346) -> impl ::core::future::Future<Output = Flag1> + Send {347async move { Host::roundtrip_flag1(*self, x).await }348}349fn roundtrip_flag2(350&mut self,351x: Flag2,352) -> impl ::core::future::Future<Output = Flag2> + Send {353async move { Host::roundtrip_flag2(*self, x).await }354}355fn roundtrip_flag4(356&mut self,357x: Flag4,358) -> impl ::core::future::Future<Output = Flag4> + Send {359async move { Host::roundtrip_flag4(*self, x).await }360}361fn roundtrip_flag8(362&mut self,363x: Flag8,364) -> impl ::core::future::Future<Output = Flag8> + Send {365async move { Host::roundtrip_flag8(*self, x).await }366}367fn roundtrip_flag16(368&mut self,369x: Flag16,370) -> impl ::core::future::Future<Output = Flag16> + Send {371async move { Host::roundtrip_flag16(*self, x).await }372}373fn roundtrip_flag32(374&mut self,375x: Flag32,376) -> impl ::core::future::Future<Output = Flag32> + Send {377async move { Host::roundtrip_flag32(*self, x).await }378}379fn roundtrip_flag64(380&mut self,381x: Flag64,382) -> impl ::core::future::Future<Output = Flag64> + Send {383async move { Host::roundtrip_flag64(*self, x).await }384}385}386pub fn add_to_linker<T, D>(387linker: &mut wasmtime::component::Linker<T>,388host_getter: fn(&mut T) -> D::Data<'_>,389) -> wasmtime::Result<()>390where391D: HostWithStore,392for<'a> D::Data<'a>: Host,393T: 'static + Send,394{395let mut inst = linker.instance("foo:foo/flegs")?;396inst.func_wrap_async(397"roundtrip-flag1",398move |399mut caller: wasmtime::StoreContextMut<'_, T>,400(arg0,): (Flag1,)|401{402use tracing::Instrument;403let span = tracing::span!(404tracing::Level::TRACE, "wit-bindgen import", module =405"flegs", function = "roundtrip-flag1",406);407wasmtime::component::__internal::Box::new(408async move {409tracing::event!(410tracing::Level::TRACE, x = tracing::field::debug(& arg0),411"call"412);413let host = &mut host_getter(caller.data_mut());414let r = Host::roundtrip_flag1(host, arg0).await;415tracing::event!(416tracing::Level::TRACE, result = tracing::field::debug(& r),417"return"418);419Ok((r,))420}421.instrument(span),422)423},424)?;425inst.func_wrap_async(426"roundtrip-flag2",427move |428mut caller: wasmtime::StoreContextMut<'_, T>,429(arg0,): (Flag2,)|430{431use tracing::Instrument;432let span = tracing::span!(433tracing::Level::TRACE, "wit-bindgen import", module =434"flegs", function = "roundtrip-flag2",435);436wasmtime::component::__internal::Box::new(437async move {438tracing::event!(439tracing::Level::TRACE, x = tracing::field::debug(& arg0),440"call"441);442let host = &mut host_getter(caller.data_mut());443let r = Host::roundtrip_flag2(host, arg0).await;444tracing::event!(445tracing::Level::TRACE, result = tracing::field::debug(& r),446"return"447);448Ok((r,))449}450.instrument(span),451)452},453)?;454inst.func_wrap_async(455"roundtrip-flag4",456move |457mut caller: wasmtime::StoreContextMut<'_, T>,458(arg0,): (Flag4,)|459{460use tracing::Instrument;461let span = tracing::span!(462tracing::Level::TRACE, "wit-bindgen import", module =463"flegs", function = "roundtrip-flag4",464);465wasmtime::component::__internal::Box::new(466async move {467tracing::event!(468tracing::Level::TRACE, x = tracing::field::debug(& arg0),469"call"470);471let host = &mut host_getter(caller.data_mut());472let r = Host::roundtrip_flag4(host, arg0).await;473tracing::event!(474tracing::Level::TRACE, result = tracing::field::debug(& r),475"return"476);477Ok((r,))478}479.instrument(span),480)481},482)?;483inst.func_wrap_async(484"roundtrip-flag8",485move |486mut caller: wasmtime::StoreContextMut<'_, T>,487(arg0,): (Flag8,)|488{489use tracing::Instrument;490let span = tracing::span!(491tracing::Level::TRACE, "wit-bindgen import", module =492"flegs", function = "roundtrip-flag8",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::roundtrip_flag8(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"roundtrip-flag16",514move |515mut caller: wasmtime::StoreContextMut<'_, T>,516(arg0,): (Flag16,)|517{518use tracing::Instrument;519let span = tracing::span!(520tracing::Level::TRACE, "wit-bindgen import", module =521"flegs", function = "roundtrip-flag16",522);523wasmtime::component::__internal::Box::new(524async move {525tracing::event!(526tracing::Level::TRACE, x = tracing::field::debug(& arg0),527"call"528);529let host = &mut host_getter(caller.data_mut());530let r = Host::roundtrip_flag16(host, arg0).await;531tracing::event!(532tracing::Level::TRACE, result = tracing::field::debug(& r),533"return"534);535Ok((r,))536}537.instrument(span),538)539},540)?;541inst.func_wrap_async(542"roundtrip-flag32",543move |544mut caller: wasmtime::StoreContextMut<'_, T>,545(arg0,): (Flag32,)|546{547use tracing::Instrument;548let span = tracing::span!(549tracing::Level::TRACE, "wit-bindgen import", module =550"flegs", function = "roundtrip-flag32",551);552wasmtime::component::__internal::Box::new(553async move {554tracing::event!(555tracing::Level::TRACE, x = tracing::field::debug(& arg0),556"call"557);558let host = &mut host_getter(caller.data_mut());559let r = Host::roundtrip_flag32(host, arg0).await;560tracing::event!(561tracing::Level::TRACE, result = tracing::field::debug(& r),562"return"563);564Ok((r,))565}566.instrument(span),567)568},569)?;570inst.func_wrap_async(571"roundtrip-flag64",572move |573mut caller: wasmtime::StoreContextMut<'_, T>,574(arg0,): (Flag64,)|575{576use tracing::Instrument;577let span = tracing::span!(578tracing::Level::TRACE, "wit-bindgen import", module =579"flegs", function = "roundtrip-flag64",580);581wasmtime::component::__internal::Box::new(582async move {583tracing::event!(584tracing::Level::TRACE, x = tracing::field::debug(& arg0),585"call"586);587let host = &mut host_getter(caller.data_mut());588let r = Host::roundtrip_flag64(host, arg0).await;589tracing::event!(590tracing::Level::TRACE, result = tracing::field::debug(& r),591"return"592);593Ok((r,))594}595.instrument(span),596)597},598)?;599Ok(())600}601}602}603}604pub mod exports {605pub mod foo {606pub mod foo {607#[allow(clippy::all)]608pub mod flegs {609#[allow(unused_imports)]610use wasmtime::component::__internal::{anyhow, Box};611wasmtime::component::flags!(612Flag1 { #[component(name = "b0")] const B0; }613);614const _: () = {615assert!(6161 == < Flag1 as wasmtime::component::ComponentType >::SIZE32617);618assert!(6191 == < Flag1 as wasmtime::component::ComponentType >::ALIGN32620);621};622wasmtime::component::flags!(623Flag2 { #[component(name = "b0")] const B0; #[component(name = "b1")]624const B1; }625);626const _: () = {627assert!(6281 == < Flag2 as wasmtime::component::ComponentType >::SIZE32629);630assert!(6311 == < Flag2 as wasmtime::component::ComponentType >::ALIGN32632);633};634wasmtime::component::flags!(635Flag4 { #[component(name = "b0")] const B0; #[component(name = "b1")]636const B1; #[component(name = "b2")] const B2; #[component(name =637"b3")] const B3; }638);639const _: () = {640assert!(6411 == < Flag4 as wasmtime::component::ComponentType >::SIZE32642);643assert!(6441 == < Flag4 as wasmtime::component::ComponentType >::ALIGN32645);646};647wasmtime::component::flags!(648Flag8 { #[component(name = "b0")] const B0; #[component(name = "b1")]649const B1; #[component(name = "b2")] const B2; #[component(name =650"b3")] const B3; #[component(name = "b4")] const B4; #[component(name651= "b5")] const B5; #[component(name = "b6")] const B6;652#[component(name = "b7")] const B7; }653);654const _: () = {655assert!(6561 == < Flag8 as wasmtime::component::ComponentType >::SIZE32657);658assert!(6591 == < Flag8 as wasmtime::component::ComponentType >::ALIGN32660);661};662wasmtime::component::flags!(663Flag16 { #[component(name = "b0")] const B0; #[component(name =664"b1")] const B1; #[component(name = "b2")] const B2; #[component(name665= "b3")] const B3; #[component(name = "b4")] const B4;666#[component(name = "b5")] const B5; #[component(name = "b6")] const667B6; #[component(name = "b7")] const B7; #[component(name = "b8")]668const B8; #[component(name = "b9")] const B9; #[component(name =669"b10")] const B10; #[component(name = "b11")] const B11;670#[component(name = "b12")] const B12; #[component(name = "b13")]671const B13; #[component(name = "b14")] const B14; #[component(name =672"b15")] const B15; }673);674const _: () = {675assert!(6762 == < Flag16 as wasmtime::component::ComponentType >::SIZE32677);678assert!(6792 == < Flag16 as wasmtime::component::ComponentType >::ALIGN32680);681};682wasmtime::component::flags!(683Flag32 { #[component(name = "b0")] const B0; #[component(name =684"b1")] const B1; #[component(name = "b2")] const B2; #[component(name685= "b3")] const B3; #[component(name = "b4")] const B4;686#[component(name = "b5")] const B5; #[component(name = "b6")] const687B6; #[component(name = "b7")] const B7; #[component(name = "b8")]688const B8; #[component(name = "b9")] const B9; #[component(name =689"b10")] const B10; #[component(name = "b11")] const B11;690#[component(name = "b12")] const B12; #[component(name = "b13")]691const B13; #[component(name = "b14")] const B14; #[component(name =692"b15")] const B15; #[component(name = "b16")] const B16;693#[component(name = "b17")] const B17; #[component(name = "b18")]694const B18; #[component(name = "b19")] const B19; #[component(name =695"b20")] const B20; #[component(name = "b21")] const B21;696#[component(name = "b22")] const B22; #[component(name = "b23")]697const B23; #[component(name = "b24")] const B24; #[component(name =698"b25")] const B25; #[component(name = "b26")] const B26;699#[component(name = "b27")] const B27; #[component(name = "b28")]700const B28; #[component(name = "b29")] const B29; #[component(name =701"b30")] const B30; #[component(name = "b31")] const B31; }702);703const _: () = {704assert!(7054 == < Flag32 as wasmtime::component::ComponentType >::SIZE32706);707assert!(7084 == < Flag32 as wasmtime::component::ComponentType >::ALIGN32709);710};711wasmtime::component::flags!(712Flag64 { #[component(name = "b0")] const B0; #[component(name =713"b1")] const B1; #[component(name = "b2")] const B2; #[component(name714= "b3")] const B3; #[component(name = "b4")] const B4;715#[component(name = "b5")] const B5; #[component(name = "b6")] const716B6; #[component(name = "b7")] const B7; #[component(name = "b8")]717const B8; #[component(name = "b9")] const B9; #[component(name =718"b10")] const B10; #[component(name = "b11")] const B11;719#[component(name = "b12")] const B12; #[component(name = "b13")]720const B13; #[component(name = "b14")] const B14; #[component(name =721"b15")] const B15; #[component(name = "b16")] const B16;722#[component(name = "b17")] const B17; #[component(name = "b18")]723const B18; #[component(name = "b19")] const B19; #[component(name =724"b20")] const B20; #[component(name = "b21")] const B21;725#[component(name = "b22")] const B22; #[component(name = "b23")]726const B23; #[component(name = "b24")] const B24; #[component(name =727"b25")] const B25; #[component(name = "b26")] const B26;728#[component(name = "b27")] const B27; #[component(name = "b28")]729const B28; #[component(name = "b29")] const B29; #[component(name =730"b30")] const B30; #[component(name = "b31")] const B31;731#[component(name = "b32")] const B32; #[component(name = "b33")]732const B33; #[component(name = "b34")] const B34; #[component(name =733"b35")] const B35; #[component(name = "b36")] const B36;734#[component(name = "b37")] const B37; #[component(name = "b38")]735const B38; #[component(name = "b39")] const B39; #[component(name =736"b40")] const B40; #[component(name = "b41")] const B41;737#[component(name = "b42")] const B42; #[component(name = "b43")]738const B43; #[component(name = "b44")] const B44; #[component(name =739"b45")] const B45; #[component(name = "b46")] const B46;740#[component(name = "b47")] const B47; #[component(name = "b48")]741const B48; #[component(name = "b49")] const B49; #[component(name =742"b50")] const B50; #[component(name = "b51")] const B51;743#[component(name = "b52")] const B52; #[component(name = "b53")]744const B53; #[component(name = "b54")] const B54; #[component(name =745"b55")] const B55; #[component(name = "b56")] const B56;746#[component(name = "b57")] const B57; #[component(name = "b58")]747const B58; #[component(name = "b59")] const B59; #[component(name =748"b60")] const B60; #[component(name = "b61")] const B61;749#[component(name = "b62")] const B62; #[component(name = "b63")]750const B63; }751);752const _: () = {753assert!(7548 == < Flag64 as wasmtime::component::ComponentType >::SIZE32755);756assert!(7574 == < Flag64 as wasmtime::component::ComponentType >::ALIGN32758);759};760pub struct Guest {761roundtrip_flag1: wasmtime::component::Func,762roundtrip_flag2: wasmtime::component::Func,763roundtrip_flag4: wasmtime::component::Func,764roundtrip_flag8: wasmtime::component::Func,765roundtrip_flag16: wasmtime::component::Func,766roundtrip_flag32: wasmtime::component::Func,767roundtrip_flag64: wasmtime::component::Func,768}769#[derive(Clone)]770pub struct GuestIndices {771roundtrip_flag1: wasmtime::component::ComponentExportIndex,772roundtrip_flag2: wasmtime::component::ComponentExportIndex,773roundtrip_flag4: wasmtime::component::ComponentExportIndex,774roundtrip_flag8: wasmtime::component::ComponentExportIndex,775roundtrip_flag16: wasmtime::component::ComponentExportIndex,776roundtrip_flag32: wasmtime::component::ComponentExportIndex,777roundtrip_flag64: wasmtime::component::ComponentExportIndex,778}779impl GuestIndices {780/// Constructor for [`GuestIndices`] which takes a781/// [`Component`](wasmtime::component::Component) as input and can be executed782/// before instantiation.783///784/// This constructor can be used to front-load string lookups to find exports785/// within a component.786pub fn new<_T>(787_instance_pre: &wasmtime::component::InstancePre<_T>,788) -> wasmtime::Result<GuestIndices> {789let instance = _instance_pre790.component()791.get_export_index(None, "foo:foo/flegs")792.ok_or_else(|| {793anyhow::anyhow!(794"no exported instance named `foo:foo/flegs`"795)796})?;797let mut lookup = move |name| {798_instance_pre799.component()800.get_export_index(Some(&instance), name)801.ok_or_else(|| {802anyhow::anyhow!(803"instance export `foo:foo/flegs` does \804not have export `{name}`"805)806})807};808let _ = &mut lookup;809let roundtrip_flag1 = lookup("roundtrip-flag1")?;810let roundtrip_flag2 = lookup("roundtrip-flag2")?;811let roundtrip_flag4 = lookup("roundtrip-flag4")?;812let roundtrip_flag8 = lookup("roundtrip-flag8")?;813let roundtrip_flag16 = lookup("roundtrip-flag16")?;814let roundtrip_flag32 = lookup("roundtrip-flag32")?;815let roundtrip_flag64 = lookup("roundtrip-flag64")?;816Ok(GuestIndices {817roundtrip_flag1,818roundtrip_flag2,819roundtrip_flag4,820roundtrip_flag8,821roundtrip_flag16,822roundtrip_flag32,823roundtrip_flag64,824})825}826pub fn load(827&self,828mut store: impl wasmtime::AsContextMut,829instance: &wasmtime::component::Instance,830) -> wasmtime::Result<Guest> {831let _instance = instance;832let _instance_pre = _instance.instance_pre(&store);833let _instance_type = _instance_pre.instance_type();834let mut store = store.as_context_mut();835let _ = &mut store;836let roundtrip_flag1 = *_instance837.get_typed_func::<838(Flag1,),839(Flag1,),840>(&mut store, &self.roundtrip_flag1)?841.func();842let roundtrip_flag2 = *_instance843.get_typed_func::<844(Flag2,),845(Flag2,),846>(&mut store, &self.roundtrip_flag2)?847.func();848let roundtrip_flag4 = *_instance849.get_typed_func::<850(Flag4,),851(Flag4,),852>(&mut store, &self.roundtrip_flag4)?853.func();854let roundtrip_flag8 = *_instance855.get_typed_func::<856(Flag8,),857(Flag8,),858>(&mut store, &self.roundtrip_flag8)?859.func();860let roundtrip_flag16 = *_instance861.get_typed_func::<862(Flag16,),863(Flag16,),864>(&mut store, &self.roundtrip_flag16)?865.func();866let roundtrip_flag32 = *_instance867.get_typed_func::<868(Flag32,),869(Flag32,),870>(&mut store, &self.roundtrip_flag32)?871.func();872let roundtrip_flag64 = *_instance873.get_typed_func::<874(Flag64,),875(Flag64,),876>(&mut store, &self.roundtrip_flag64)?877.func();878Ok(Guest {879roundtrip_flag1,880roundtrip_flag2,881roundtrip_flag4,882roundtrip_flag8,883roundtrip_flag16,884roundtrip_flag32,885roundtrip_flag64,886})887}888}889impl Guest {890pub async fn call_roundtrip_flag1<S: wasmtime::AsContextMut>(891&self,892mut store: S,893arg0: Flag1,894) -> wasmtime::Result<Flag1>895where896<S as wasmtime::AsContext>::Data: Send,897{898use tracing::Instrument;899let span = tracing::span!(900tracing::Level::TRACE, "wit-bindgen export", module =901"foo:foo/flegs", function = "roundtrip-flag1",902);903let callee = unsafe {904wasmtime::component::TypedFunc::<905(Flag1,),906(Flag1,),907>::new_unchecked(self.roundtrip_flag1)908};909let (ret0,) = callee910.call_async(store.as_context_mut(), (arg0,))911.instrument(span.clone())912.await?;913callee914.post_return_async(store.as_context_mut())915.instrument(span)916.await?;917Ok(ret0)918}919pub async fn call_roundtrip_flag2<S: wasmtime::AsContextMut>(920&self,921mut store: S,922arg0: Flag2,923) -> wasmtime::Result<Flag2>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/flegs", function = "roundtrip-flag2",931);932let callee = unsafe {933wasmtime::component::TypedFunc::<934(Flag2,),935(Flag2,),936>::new_unchecked(self.roundtrip_flag2)937};938let (ret0,) = callee939.call_async(store.as_context_mut(), (arg0,))940.instrument(span.clone())941.await?;942callee943.post_return_async(store.as_context_mut())944.instrument(span)945.await?;946Ok(ret0)947}948pub async fn call_roundtrip_flag4<S: wasmtime::AsContextMut>(949&self,950mut store: S,951arg0: Flag4,952) -> wasmtime::Result<Flag4>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/flegs", function = "roundtrip-flag4",960);961let callee = unsafe {962wasmtime::component::TypedFunc::<963(Flag4,),964(Flag4,),965>::new_unchecked(self.roundtrip_flag4)966};967let (ret0,) = callee968.call_async(store.as_context_mut(), (arg0,))969.instrument(span.clone())970.await?;971callee972.post_return_async(store.as_context_mut())973.instrument(span)974.await?;975Ok(ret0)976}977pub async fn call_roundtrip_flag8<S: wasmtime::AsContextMut>(978&self,979mut store: S,980arg0: Flag8,981) -> wasmtime::Result<Flag8>982where983<S as wasmtime::AsContext>::Data: Send,984{985use tracing::Instrument;986let span = tracing::span!(987tracing::Level::TRACE, "wit-bindgen export", module =988"foo:foo/flegs", function = "roundtrip-flag8",989);990let callee = unsafe {991wasmtime::component::TypedFunc::<992(Flag8,),993(Flag8,),994>::new_unchecked(self.roundtrip_flag8)995};996let (ret0,) = callee997.call_async(store.as_context_mut(), (arg0,))998.instrument(span.clone())999.await?;1000callee1001.post_return_async(store.as_context_mut())1002.instrument(span)1003.await?;1004Ok(ret0)1005}1006pub async fn call_roundtrip_flag16<S: wasmtime::AsContextMut>(1007&self,1008mut store: S,1009arg0: Flag16,1010) -> wasmtime::Result<Flag16>1011where1012<S as wasmtime::AsContext>::Data: Send,1013{1014use tracing::Instrument;1015let span = tracing::span!(1016tracing::Level::TRACE, "wit-bindgen export", module =1017"foo:foo/flegs", function = "roundtrip-flag16",1018);1019let callee = unsafe {1020wasmtime::component::TypedFunc::<1021(Flag16,),1022(Flag16,),1023>::new_unchecked(self.roundtrip_flag16)1024};1025let (ret0,) = callee1026.call_async(store.as_context_mut(), (arg0,))1027.instrument(span.clone())1028.await?;1029callee1030.post_return_async(store.as_context_mut())1031.instrument(span)1032.await?;1033Ok(ret0)1034}1035pub async fn call_roundtrip_flag32<S: wasmtime::AsContextMut>(1036&self,1037mut store: S,1038arg0: Flag32,1039) -> wasmtime::Result<Flag32>1040where1041<S as wasmtime::AsContext>::Data: Send,1042{1043use tracing::Instrument;1044let span = tracing::span!(1045tracing::Level::TRACE, "wit-bindgen export", module =1046"foo:foo/flegs", function = "roundtrip-flag32",1047);1048let callee = unsafe {1049wasmtime::component::TypedFunc::<1050(Flag32,),1051(Flag32,),1052>::new_unchecked(self.roundtrip_flag32)1053};1054let (ret0,) = callee1055.call_async(store.as_context_mut(), (arg0,))1056.instrument(span.clone())1057.await?;1058callee1059.post_return_async(store.as_context_mut())1060.instrument(span)1061.await?;1062Ok(ret0)1063}1064pub async fn call_roundtrip_flag64<S: wasmtime::AsContextMut>(1065&self,1066mut store: S,1067arg0: Flag64,1068) -> wasmtime::Result<Flag64>1069where1070<S as wasmtime::AsContext>::Data: Send,1071{1072use tracing::Instrument;1073let span = tracing::span!(1074tracing::Level::TRACE, "wit-bindgen export", module =1075"foo:foo/flegs", function = "roundtrip-flag64",1076);1077let callee = unsafe {1078wasmtime::component::TypedFunc::<1079(Flag64,),1080(Flag64,),1081>::new_unchecked(self.roundtrip_flag64)1082};1083let (ret0,) = callee1084.call_async(store.as_context_mut(), (arg0,))1085.instrument(span.clone())1086.await?;1087callee1088.post_return_async(store.as_context_mut())1089.instrument(span)1090.await?;1091Ok(ret0)1092}1093}1094}1095}1096}1097}109810991100