Path: blob/main/crates/component-macro/tests/expanded/flags_tracing_async.rs
3076 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 _: () = {105impl TheFlagsIndices {106/// Creates a new copy of `TheFlagsIndices` bindings which can then107/// be used to instantiate into a particular store.108///109/// This method may fail if the component does not have the110/// required exports.111pub fn new<_T>(112_instance_pre: &wasmtime::component::InstancePre<_T>,113) -> wasmtime::Result<Self> {114let _component = _instance_pre.component();115let _instance_type = _instance_pre.instance_type();116let interface0 = exports::foo::foo::flegs::GuestIndices::new(_instance_pre)?;117Ok(TheFlagsIndices { interface0 })118}119/// Uses the indices stored in `self` to load an instance120/// of [`TheFlags`] from the instance provided.121///122/// Note that at this time this method will additionally123/// perform type-checks of all exports.124pub fn load(125&self,126mut store: impl wasmtime::AsContextMut,127instance: &wasmtime::component::Instance,128) -> wasmtime::Result<TheFlags> {129let _ = &mut store;130let _instance = instance;131let interface0 = self.interface0.load(&mut store, &_instance)?;132Ok(TheFlags { interface0 })133}134}135impl TheFlags {136/// Convenience wrapper around [`TheFlagsPre::new`] and137/// [`TheFlagsPre::instantiate`].138pub fn instantiate<_T>(139store: impl wasmtime::AsContextMut<Data = _T>,140component: &wasmtime::component::Component,141linker: &wasmtime::component::Linker<_T>,142) -> wasmtime::Result<TheFlags> {143let pre = linker.instantiate_pre(component)?;144TheFlagsPre::new(pre)?.instantiate(store)145}146/// Convenience wrapper around [`TheFlagsIndices::new`] and147/// [`TheFlagsIndices::load`].148pub fn new(149mut store: impl wasmtime::AsContextMut,150instance: &wasmtime::component::Instance,151) -> wasmtime::Result<TheFlags> {152let indices = TheFlagsIndices::new(&instance.instance_pre(&store))?;153indices.load(&mut store, instance)154}155/// Convenience wrapper around [`TheFlagsPre::new`] and156/// [`TheFlagsPre::instantiate_async`].157pub async fn instantiate_async<_T>(158store: impl wasmtime::AsContextMut<Data = _T>,159component: &wasmtime::component::Component,160linker: &wasmtime::component::Linker<_T>,161) -> wasmtime::Result<TheFlags>162where163_T: Send,164{165let pre = linker.instantiate_pre(component)?;166TheFlagsPre::new(pre)?.instantiate_async(store).await167}168pub fn add_to_linker<T, D>(169linker: &mut wasmtime::component::Linker<T>,170host_getter: fn(&mut T) -> D::Data<'_>,171) -> wasmtime::Result<()>172where173D: foo::foo::flegs::HostWithStore + Send,174for<'a> D::Data<'a>: foo::foo::flegs::Host + Send,175T: 'static + Send,176{177foo::foo::flegs::add_to_linker::<T, D>(linker, host_getter)?;178Ok(())179}180pub fn foo_foo_flegs(&self) -> &exports::foo::foo::flegs::Guest {181&self.interface0182}183}184};185pub mod foo {186pub mod foo {187#[allow(clippy::all)]188pub mod flegs {189#[allow(unused_imports)]190use wasmtime::component::__internal::Box;191wasmtime::component::flags!(Flag1 { #[component(name = "b0")] const B0; });192const _: () = {193assert!(1 == < Flag1 as wasmtime::component::ComponentType >::SIZE32);194assert!(1 == < Flag1 as wasmtime::component::ComponentType >::ALIGN32);195};196wasmtime::component::flags!(197Flag2 { #[component(name = "b0")] const B0; #[component(name = "b1")]198const B1; }199);200const _: () = {201assert!(1 == < Flag2 as wasmtime::component::ComponentType >::SIZE32);202assert!(1 == < Flag2 as wasmtime::component::ComponentType >::ALIGN32);203};204wasmtime::component::flags!(205Flag4 { #[component(name = "b0")] const B0; #[component(name = "b1")]206const B1; #[component(name = "b2")] const B2; #[component(name = "b3")]207const B3; }208);209const _: () = {210assert!(1 == < Flag4 as wasmtime::component::ComponentType >::SIZE32);211assert!(1 == < Flag4 as wasmtime::component::ComponentType >::ALIGN32);212};213wasmtime::component::flags!(214Flag8 { #[component(name = "b0")] const B0; #[component(name = "b1")]215const B1; #[component(name = "b2")] const B2; #[component(name = "b3")]216const B3; #[component(name = "b4")] const B4; #[component(name = "b5")]217const B5; #[component(name = "b6")] const B6; #[component(name = "b7")]218const B7; }219);220const _: () = {221assert!(1 == < Flag8 as wasmtime::component::ComponentType >::SIZE32);222assert!(1 == < Flag8 as wasmtime::component::ComponentType >::ALIGN32);223};224wasmtime::component::flags!(225Flag16 { #[component(name = "b0")] const B0; #[component(name = "b1")]226const B1; #[component(name = "b2")] const B2; #[component(name = "b3")]227const B3; #[component(name = "b4")] const B4; #[component(name = "b5")]228const B5; #[component(name = "b6")] const B6; #[component(name = "b7")]229const B7; #[component(name = "b8")] const B8; #[component(name = "b9")]230const B9; #[component(name = "b10")] const B10; #[component(name =231"b11")] const B11; #[component(name = "b12")] const B12; #[component(name232= "b13")] const B13; #[component(name = "b14")] const B14;233#[component(name = "b15")] const B15; }234);235const _: () = {236assert!(2 == < Flag16 as wasmtime::component::ComponentType >::SIZE32);237assert!(2 == < Flag16 as wasmtime::component::ComponentType >::ALIGN32);238};239wasmtime::component::flags!(240Flag32 { #[component(name = "b0")] const B0; #[component(name = "b1")]241const B1; #[component(name = "b2")] const B2; #[component(name = "b3")]242const B3; #[component(name = "b4")] const B4; #[component(name = "b5")]243const B5; #[component(name = "b6")] const B6; #[component(name = "b7")]244const B7; #[component(name = "b8")] const B8; #[component(name = "b9")]245const B9; #[component(name = "b10")] const B10; #[component(name =246"b11")] const B11; #[component(name = "b12")] const B12; #[component(name247= "b13")] const B13; #[component(name = "b14")] const B14;248#[component(name = "b15")] const B15; #[component(name = "b16")] const249B16; #[component(name = "b17")] const B17; #[component(name = "b18")]250const B18; #[component(name = "b19")] const B19; #[component(name =251"b20")] const B20; #[component(name = "b21")] const B21; #[component(name252= "b22")] const B22; #[component(name = "b23")] const B23;253#[component(name = "b24")] const B24; #[component(name = "b25")] const254B25; #[component(name = "b26")] const B26; #[component(name = "b27")]255const B27; #[component(name = "b28")] const B28; #[component(name =256"b29")] const B29; #[component(name = "b30")] const B30; #[component(name257= "b31")] const B31; }258);259const _: () = {260assert!(4 == < Flag32 as wasmtime::component::ComponentType >::SIZE32);261assert!(4 == < Flag32 as wasmtime::component::ComponentType >::ALIGN32);262};263wasmtime::component::flags!(264Flag64 { #[component(name = "b0")] const B0; #[component(name = "b1")]265const B1; #[component(name = "b2")] const B2; #[component(name = "b3")]266const B3; #[component(name = "b4")] const B4; #[component(name = "b5")]267const B5; #[component(name = "b6")] const B6; #[component(name = "b7")]268const B7; #[component(name = "b8")] const B8; #[component(name = "b9")]269const B9; #[component(name = "b10")] const B10; #[component(name =270"b11")] const B11; #[component(name = "b12")] const B12; #[component(name271= "b13")] const B13; #[component(name = "b14")] const B14;272#[component(name = "b15")] const B15; #[component(name = "b16")] const273B16; #[component(name = "b17")] const B17; #[component(name = "b18")]274const B18; #[component(name = "b19")] const B19; #[component(name =275"b20")] const B20; #[component(name = "b21")] const B21; #[component(name276= "b22")] const B22; #[component(name = "b23")] const B23;277#[component(name = "b24")] const B24; #[component(name = "b25")] const278B25; #[component(name = "b26")] const B26; #[component(name = "b27")]279const B27; #[component(name = "b28")] const B28; #[component(name =280"b29")] const B29; #[component(name = "b30")] const B30; #[component(name281= "b31")] const B31; #[component(name = "b32")] const B32;282#[component(name = "b33")] const B33; #[component(name = "b34")] const283B34; #[component(name = "b35")] const B35; #[component(name = "b36")]284const B36; #[component(name = "b37")] const B37; #[component(name =285"b38")] const B38; #[component(name = "b39")] const B39; #[component(name286= "b40")] const B40; #[component(name = "b41")] const B41;287#[component(name = "b42")] const B42; #[component(name = "b43")] const288B43; #[component(name = "b44")] const B44; #[component(name = "b45")]289const B45; #[component(name = "b46")] const B46; #[component(name =290"b47")] const B47; #[component(name = "b48")] const B48; #[component(name291= "b49")] const B49; #[component(name = "b50")] const B50;292#[component(name = "b51")] const B51; #[component(name = "b52")] const293B52; #[component(name = "b53")] const B53; #[component(name = "b54")]294const B54; #[component(name = "b55")] const B55; #[component(name =295"b56")] const B56; #[component(name = "b57")] const B57; #[component(name296= "b58")] const B58; #[component(name = "b59")] const B59;297#[component(name = "b60")] const B60; #[component(name = "b61")] const298B61; #[component(name = "b62")] const B62; #[component(name = "b63")]299const B63; }300);301const _: () = {302assert!(8 == < Flag64 as wasmtime::component::ComponentType >::SIZE32);303assert!(4 == < Flag64 as wasmtime::component::ComponentType >::ALIGN32);304};305pub trait HostWithStore: wasmtime::component::HasData + Send {}306impl<_T: ?Sized> HostWithStore for _T307where308_T: wasmtime::component::HasData + Send,309{}310pub trait Host: Send {311fn roundtrip_flag1(312&mut self,313x: Flag1,314) -> impl ::core::future::Future<Output = Flag1> + Send;315fn roundtrip_flag2(316&mut self,317x: Flag2,318) -> impl ::core::future::Future<Output = Flag2> + Send;319fn roundtrip_flag4(320&mut self,321x: Flag4,322) -> impl ::core::future::Future<Output = Flag4> + Send;323fn roundtrip_flag8(324&mut self,325x: Flag8,326) -> impl ::core::future::Future<Output = Flag8> + Send;327fn roundtrip_flag16(328&mut self,329x: Flag16,330) -> impl ::core::future::Future<Output = Flag16> + Send;331fn roundtrip_flag32(332&mut self,333x: Flag32,334) -> impl ::core::future::Future<Output = Flag32> + Send;335fn roundtrip_flag64(336&mut self,337x: Flag64,338) -> impl ::core::future::Future<Output = Flag64> + Send;339}340impl<_T: Host + ?Sized + Send> Host for &mut _T {341fn roundtrip_flag1(342&mut self,343x: Flag1,344) -> impl ::core::future::Future<Output = Flag1> + Send {345async move { Host::roundtrip_flag1(*self, x).await }346}347fn roundtrip_flag2(348&mut self,349x: Flag2,350) -> impl ::core::future::Future<Output = Flag2> + Send {351async move { Host::roundtrip_flag2(*self, x).await }352}353fn roundtrip_flag4(354&mut self,355x: Flag4,356) -> impl ::core::future::Future<Output = Flag4> + Send {357async move { Host::roundtrip_flag4(*self, x).await }358}359fn roundtrip_flag8(360&mut self,361x: Flag8,362) -> impl ::core::future::Future<Output = Flag8> + Send {363async move { Host::roundtrip_flag8(*self, x).await }364}365fn roundtrip_flag16(366&mut self,367x: Flag16,368) -> impl ::core::future::Future<Output = Flag16> + Send {369async move { Host::roundtrip_flag16(*self, x).await }370}371fn roundtrip_flag32(372&mut self,373x: Flag32,374) -> impl ::core::future::Future<Output = Flag32> + Send {375async move { Host::roundtrip_flag32(*self, x).await }376}377fn roundtrip_flag64(378&mut self,379x: Flag64,380) -> impl ::core::future::Future<Output = Flag64> + Send {381async move { Host::roundtrip_flag64(*self, x).await }382}383}384pub fn add_to_linker<T, D>(385linker: &mut wasmtime::component::Linker<T>,386host_getter: fn(&mut T) -> D::Data<'_>,387) -> wasmtime::Result<()>388where389D: HostWithStore,390for<'a> D::Data<'a>: Host,391T: 'static + Send,392{393let mut inst = linker.instance("foo:foo/flegs")?;394inst.func_wrap_async(395"roundtrip-flag1",396move |397mut caller: wasmtime::StoreContextMut<'_, T>,398(arg0,): (Flag1,)|399{400use tracing::Instrument;401let span = tracing::span!(402tracing::Level::TRACE, "wit-bindgen import", module =403"flegs", function = "roundtrip-flag1",404);405wasmtime::component::__internal::Box::new(406async move {407tracing::event!(408tracing::Level::TRACE, x = tracing::field::debug(& arg0),409"call"410);411let host = &mut host_getter(caller.data_mut());412let r = Host::roundtrip_flag1(host, arg0).await;413tracing::event!(414tracing::Level::TRACE, result = tracing::field::debug(& r),415"return"416);417Ok((r,))418}419.instrument(span),420)421},422)?;423inst.func_wrap_async(424"roundtrip-flag2",425move |426mut caller: wasmtime::StoreContextMut<'_, T>,427(arg0,): (Flag2,)|428{429use tracing::Instrument;430let span = tracing::span!(431tracing::Level::TRACE, "wit-bindgen import", module =432"flegs", function = "roundtrip-flag2",433);434wasmtime::component::__internal::Box::new(435async move {436tracing::event!(437tracing::Level::TRACE, x = tracing::field::debug(& arg0),438"call"439);440let host = &mut host_getter(caller.data_mut());441let r = Host::roundtrip_flag2(host, arg0).await;442tracing::event!(443tracing::Level::TRACE, result = tracing::field::debug(& r),444"return"445);446Ok((r,))447}448.instrument(span),449)450},451)?;452inst.func_wrap_async(453"roundtrip-flag4",454move |455mut caller: wasmtime::StoreContextMut<'_, T>,456(arg0,): (Flag4,)|457{458use tracing::Instrument;459let span = tracing::span!(460tracing::Level::TRACE, "wit-bindgen import", module =461"flegs", function = "roundtrip-flag4",462);463wasmtime::component::__internal::Box::new(464async move {465tracing::event!(466tracing::Level::TRACE, x = tracing::field::debug(& arg0),467"call"468);469let host = &mut host_getter(caller.data_mut());470let r = Host::roundtrip_flag4(host, arg0).await;471tracing::event!(472tracing::Level::TRACE, result = tracing::field::debug(& r),473"return"474);475Ok((r,))476}477.instrument(span),478)479},480)?;481inst.func_wrap_async(482"roundtrip-flag8",483move |484mut caller: wasmtime::StoreContextMut<'_, T>,485(arg0,): (Flag8,)|486{487use tracing::Instrument;488let span = tracing::span!(489tracing::Level::TRACE, "wit-bindgen import", module =490"flegs", function = "roundtrip-flag8",491);492wasmtime::component::__internal::Box::new(493async move {494tracing::event!(495tracing::Level::TRACE, x = tracing::field::debug(& arg0),496"call"497);498let host = &mut host_getter(caller.data_mut());499let r = Host::roundtrip_flag8(host, arg0).await;500tracing::event!(501tracing::Level::TRACE, result = tracing::field::debug(& r),502"return"503);504Ok((r,))505}506.instrument(span),507)508},509)?;510inst.func_wrap_async(511"roundtrip-flag16",512move |513mut caller: wasmtime::StoreContextMut<'_, T>,514(arg0,): (Flag16,)|515{516use tracing::Instrument;517let span = tracing::span!(518tracing::Level::TRACE, "wit-bindgen import", module =519"flegs", function = "roundtrip-flag16",520);521wasmtime::component::__internal::Box::new(522async move {523tracing::event!(524tracing::Level::TRACE, x = tracing::field::debug(& arg0),525"call"526);527let host = &mut host_getter(caller.data_mut());528let r = Host::roundtrip_flag16(host, arg0).await;529tracing::event!(530tracing::Level::TRACE, result = tracing::field::debug(& r),531"return"532);533Ok((r,))534}535.instrument(span),536)537},538)?;539inst.func_wrap_async(540"roundtrip-flag32",541move |542mut caller: wasmtime::StoreContextMut<'_, T>,543(arg0,): (Flag32,)|544{545use tracing::Instrument;546let span = tracing::span!(547tracing::Level::TRACE, "wit-bindgen import", module =548"flegs", function = "roundtrip-flag32",549);550wasmtime::component::__internal::Box::new(551async move {552tracing::event!(553tracing::Level::TRACE, x = tracing::field::debug(& arg0),554"call"555);556let host = &mut host_getter(caller.data_mut());557let r = Host::roundtrip_flag32(host, arg0).await;558tracing::event!(559tracing::Level::TRACE, result = tracing::field::debug(& r),560"return"561);562Ok((r,))563}564.instrument(span),565)566},567)?;568inst.func_wrap_async(569"roundtrip-flag64",570move |571mut caller: wasmtime::StoreContextMut<'_, T>,572(arg0,): (Flag64,)|573{574use tracing::Instrument;575let span = tracing::span!(576tracing::Level::TRACE, "wit-bindgen import", module =577"flegs", function = "roundtrip-flag64",578);579wasmtime::component::__internal::Box::new(580async move {581tracing::event!(582tracing::Level::TRACE, x = tracing::field::debug(& arg0),583"call"584);585let host = &mut host_getter(caller.data_mut());586let r = Host::roundtrip_flag64(host, arg0).await;587tracing::event!(588tracing::Level::TRACE, result = tracing::field::debug(& r),589"return"590);591Ok((r,))592}593.instrument(span),594)595},596)?;597Ok(())598}599}600}601}602pub mod exports {603pub mod foo {604pub mod foo {605#[allow(clippy::all)]606pub mod flegs {607#[allow(unused_imports)]608use wasmtime::component::__internal::Box;609wasmtime::component::flags!(610Flag1 { #[component(name = "b0")] const B0; }611);612const _: () = {613assert!(6141 == < Flag1 as wasmtime::component::ComponentType >::SIZE32615);616assert!(6171 == < Flag1 as wasmtime::component::ComponentType >::ALIGN32618);619};620wasmtime::component::flags!(621Flag2 { #[component(name = "b0")] const B0; #[component(name = "b1")]622const B1; }623);624const _: () = {625assert!(6261 == < Flag2 as wasmtime::component::ComponentType >::SIZE32627);628assert!(6291 == < Flag2 as wasmtime::component::ComponentType >::ALIGN32630);631};632wasmtime::component::flags!(633Flag4 { #[component(name = "b0")] const B0; #[component(name = "b1")]634const B1; #[component(name = "b2")] const B2; #[component(name =635"b3")] const B3; }636);637const _: () = {638assert!(6391 == < Flag4 as wasmtime::component::ComponentType >::SIZE32640);641assert!(6421 == < Flag4 as wasmtime::component::ComponentType >::ALIGN32643);644};645wasmtime::component::flags!(646Flag8 { #[component(name = "b0")] const B0; #[component(name = "b1")]647const B1; #[component(name = "b2")] const B2; #[component(name =648"b3")] const B3; #[component(name = "b4")] const B4; #[component(name649= "b5")] const B5; #[component(name = "b6")] const B6;650#[component(name = "b7")] const B7; }651);652const _: () = {653assert!(6541 == < Flag8 as wasmtime::component::ComponentType >::SIZE32655);656assert!(6571 == < Flag8 as wasmtime::component::ComponentType >::ALIGN32658);659};660wasmtime::component::flags!(661Flag16 { #[component(name = "b0")] const B0; #[component(name =662"b1")] const B1; #[component(name = "b2")] const B2; #[component(name663= "b3")] const B3; #[component(name = "b4")] const B4;664#[component(name = "b5")] const B5; #[component(name = "b6")] const665B6; #[component(name = "b7")] const B7; #[component(name = "b8")]666const B8; #[component(name = "b9")] const B9; #[component(name =667"b10")] const B10; #[component(name = "b11")] const B11;668#[component(name = "b12")] const B12; #[component(name = "b13")]669const B13; #[component(name = "b14")] const B14; #[component(name =670"b15")] const B15; }671);672const _: () = {673assert!(6742 == < Flag16 as wasmtime::component::ComponentType >::SIZE32675);676assert!(6772 == < Flag16 as wasmtime::component::ComponentType >::ALIGN32678);679};680wasmtime::component::flags!(681Flag32 { #[component(name = "b0")] const B0; #[component(name =682"b1")] const B1; #[component(name = "b2")] const B2; #[component(name683= "b3")] const B3; #[component(name = "b4")] const B4;684#[component(name = "b5")] const B5; #[component(name = "b6")] const685B6; #[component(name = "b7")] const B7; #[component(name = "b8")]686const B8; #[component(name = "b9")] const B9; #[component(name =687"b10")] const B10; #[component(name = "b11")] const B11;688#[component(name = "b12")] const B12; #[component(name = "b13")]689const B13; #[component(name = "b14")] const B14; #[component(name =690"b15")] const B15; #[component(name = "b16")] const B16;691#[component(name = "b17")] const B17; #[component(name = "b18")]692const B18; #[component(name = "b19")] const B19; #[component(name =693"b20")] const B20; #[component(name = "b21")] const B21;694#[component(name = "b22")] const B22; #[component(name = "b23")]695const B23; #[component(name = "b24")] const B24; #[component(name =696"b25")] const B25; #[component(name = "b26")] const B26;697#[component(name = "b27")] const B27; #[component(name = "b28")]698const B28; #[component(name = "b29")] const B29; #[component(name =699"b30")] const B30; #[component(name = "b31")] const B31; }700);701const _: () = {702assert!(7034 == < Flag32 as wasmtime::component::ComponentType >::SIZE32704);705assert!(7064 == < Flag32 as wasmtime::component::ComponentType >::ALIGN32707);708};709wasmtime::component::flags!(710Flag64 { #[component(name = "b0")] const B0; #[component(name =711"b1")] const B1; #[component(name = "b2")] const B2; #[component(name712= "b3")] const B3; #[component(name = "b4")] const B4;713#[component(name = "b5")] const B5; #[component(name = "b6")] const714B6; #[component(name = "b7")] const B7; #[component(name = "b8")]715const B8; #[component(name = "b9")] const B9; #[component(name =716"b10")] const B10; #[component(name = "b11")] const B11;717#[component(name = "b12")] const B12; #[component(name = "b13")]718const B13; #[component(name = "b14")] const B14; #[component(name =719"b15")] const B15; #[component(name = "b16")] const B16;720#[component(name = "b17")] const B17; #[component(name = "b18")]721const B18; #[component(name = "b19")] const B19; #[component(name =722"b20")] const B20; #[component(name = "b21")] const B21;723#[component(name = "b22")] const B22; #[component(name = "b23")]724const B23; #[component(name = "b24")] const B24; #[component(name =725"b25")] const B25; #[component(name = "b26")] const B26;726#[component(name = "b27")] const B27; #[component(name = "b28")]727const B28; #[component(name = "b29")] const B29; #[component(name =728"b30")] const B30; #[component(name = "b31")] const B31;729#[component(name = "b32")] const B32; #[component(name = "b33")]730const B33; #[component(name = "b34")] const B34; #[component(name =731"b35")] const B35; #[component(name = "b36")] const B36;732#[component(name = "b37")] const B37; #[component(name = "b38")]733const B38; #[component(name = "b39")] const B39; #[component(name =734"b40")] const B40; #[component(name = "b41")] const B41;735#[component(name = "b42")] const B42; #[component(name = "b43")]736const B43; #[component(name = "b44")] const B44; #[component(name =737"b45")] const B45; #[component(name = "b46")] const B46;738#[component(name = "b47")] const B47; #[component(name = "b48")]739const B48; #[component(name = "b49")] const B49; #[component(name =740"b50")] const B50; #[component(name = "b51")] const B51;741#[component(name = "b52")] const B52; #[component(name = "b53")]742const B53; #[component(name = "b54")] const B54; #[component(name =743"b55")] const B55; #[component(name = "b56")] const B56;744#[component(name = "b57")] const B57; #[component(name = "b58")]745const B58; #[component(name = "b59")] const B59; #[component(name =746"b60")] const B60; #[component(name = "b61")] const B61;747#[component(name = "b62")] const B62; #[component(name = "b63")]748const B63; }749);750const _: () = {751assert!(7528 == < Flag64 as wasmtime::component::ComponentType >::SIZE32753);754assert!(7554 == < Flag64 as wasmtime::component::ComponentType >::ALIGN32756);757};758#[derive(Clone)]759pub struct Guest {760roundtrip_flag1: wasmtime::component::Func,761roundtrip_flag2: wasmtime::component::Func,762roundtrip_flag4: wasmtime::component::Func,763roundtrip_flag8: wasmtime::component::Func,764roundtrip_flag16: wasmtime::component::Func,765roundtrip_flag32: wasmtime::component::Func,766roundtrip_flag64: wasmtime::component::Func,767}768#[derive(Clone)]769pub struct GuestIndices {770roundtrip_flag1: wasmtime::component::ComponentExportIndex,771roundtrip_flag2: wasmtime::component::ComponentExportIndex,772roundtrip_flag4: wasmtime::component::ComponentExportIndex,773roundtrip_flag8: wasmtime::component::ComponentExportIndex,774roundtrip_flag16: wasmtime::component::ComponentExportIndex,775roundtrip_flag32: wasmtime::component::ComponentExportIndex,776roundtrip_flag64: wasmtime::component::ComponentExportIndex,777}778impl GuestIndices {779/// Constructor for [`GuestIndices`] which takes a780/// [`Component`](wasmtime::component::Component) as input and can be executed781/// before instantiation.782///783/// This constructor can be used to front-load string lookups to find exports784/// within a component.785pub fn new<_T>(786_instance_pre: &wasmtime::component::InstancePre<_T>,787) -> wasmtime::Result<GuestIndices> {788let instance = _instance_pre789.component()790.get_export_index(None, "foo:foo/flegs")791.ok_or_else(|| {792wasmtime::format_err!(793"no exported instance named `foo:foo/flegs`"794)795})?;796let mut lookup = move |name| {797_instance_pre798.component()799.get_export_index(Some(&instance), name)800.ok_or_else(|| {801wasmtime::format_err!(802"instance export `foo:foo/flegs` does \803not have export `{name}`"804)805})806};807let _ = &mut lookup;808let roundtrip_flag1 = lookup("roundtrip-flag1")?;809let roundtrip_flag2 = lookup("roundtrip-flag2")?;810let roundtrip_flag4 = lookup("roundtrip-flag4")?;811let roundtrip_flag8 = lookup("roundtrip-flag8")?;812let roundtrip_flag16 = lookup("roundtrip-flag16")?;813let roundtrip_flag32 = lookup("roundtrip-flag32")?;814let roundtrip_flag64 = lookup("roundtrip-flag64")?;815Ok(GuestIndices {816roundtrip_flag1,817roundtrip_flag2,818roundtrip_flag4,819roundtrip_flag8,820roundtrip_flag16,821roundtrip_flag32,822roundtrip_flag64,823})824}825pub fn load(826&self,827mut store: impl wasmtime::AsContextMut,828instance: &wasmtime::component::Instance,829) -> wasmtime::Result<Guest> {830let _instance = instance;831let _instance_pre = _instance.instance_pre(&store);832let _instance_type = _instance_pre.instance_type();833let mut store = store.as_context_mut();834let _ = &mut store;835let roundtrip_flag1 = *_instance836.get_typed_func::<837(Flag1,),838(Flag1,),839>(&mut store, &self.roundtrip_flag1)?840.func();841let roundtrip_flag2 = *_instance842.get_typed_func::<843(Flag2,),844(Flag2,),845>(&mut store, &self.roundtrip_flag2)?846.func();847let roundtrip_flag4 = *_instance848.get_typed_func::<849(Flag4,),850(Flag4,),851>(&mut store, &self.roundtrip_flag4)?852.func();853let roundtrip_flag8 = *_instance854.get_typed_func::<855(Flag8,),856(Flag8,),857>(&mut store, &self.roundtrip_flag8)?858.func();859let roundtrip_flag16 = *_instance860.get_typed_func::<861(Flag16,),862(Flag16,),863>(&mut store, &self.roundtrip_flag16)?864.func();865let roundtrip_flag32 = *_instance866.get_typed_func::<867(Flag32,),868(Flag32,),869>(&mut store, &self.roundtrip_flag32)?870.func();871let roundtrip_flag64 = *_instance872.get_typed_func::<873(Flag64,),874(Flag64,),875>(&mut store, &self.roundtrip_flag64)?876.func();877Ok(Guest {878roundtrip_flag1,879roundtrip_flag2,880roundtrip_flag4,881roundtrip_flag8,882roundtrip_flag16,883roundtrip_flag32,884roundtrip_flag64,885})886}887}888impl Guest {889pub async fn call_roundtrip_flag1<S: wasmtime::AsContextMut>(890&self,891mut store: S,892arg0: Flag1,893) -> wasmtime::Result<Flag1>894where895<S as wasmtime::AsContext>::Data: Send,896{897use tracing::Instrument;898let span = tracing::span!(899tracing::Level::TRACE, "wit-bindgen export", module =900"foo:foo/flegs", function = "roundtrip-flag1",901);902let callee = unsafe {903wasmtime::component::TypedFunc::<904(Flag1,),905(Flag1,),906>::new_unchecked(self.roundtrip_flag1)907};908let (ret0,) = callee909.call_async(store.as_context_mut(), (arg0,))910.instrument(span.clone())911.await?;912Ok(ret0)913}914pub async fn call_roundtrip_flag2<S: wasmtime::AsContextMut>(915&self,916mut store: S,917arg0: Flag2,918) -> wasmtime::Result<Flag2>919where920<S as wasmtime::AsContext>::Data: Send,921{922use tracing::Instrument;923let span = tracing::span!(924tracing::Level::TRACE, "wit-bindgen export", module =925"foo:foo/flegs", function = "roundtrip-flag2",926);927let callee = unsafe {928wasmtime::component::TypedFunc::<929(Flag2,),930(Flag2,),931>::new_unchecked(self.roundtrip_flag2)932};933let (ret0,) = callee934.call_async(store.as_context_mut(), (arg0,))935.instrument(span.clone())936.await?;937Ok(ret0)938}939pub async fn call_roundtrip_flag4<S: wasmtime::AsContextMut>(940&self,941mut store: S,942arg0: Flag4,943) -> wasmtime::Result<Flag4>944where945<S as wasmtime::AsContext>::Data: Send,946{947use tracing::Instrument;948let span = tracing::span!(949tracing::Level::TRACE, "wit-bindgen export", module =950"foo:foo/flegs", function = "roundtrip-flag4",951);952let callee = unsafe {953wasmtime::component::TypedFunc::<954(Flag4,),955(Flag4,),956>::new_unchecked(self.roundtrip_flag4)957};958let (ret0,) = callee959.call_async(store.as_context_mut(), (arg0,))960.instrument(span.clone())961.await?;962Ok(ret0)963}964pub async fn call_roundtrip_flag8<S: wasmtime::AsContextMut>(965&self,966mut store: S,967arg0: Flag8,968) -> wasmtime::Result<Flag8>969where970<S as wasmtime::AsContext>::Data: Send,971{972use tracing::Instrument;973let span = tracing::span!(974tracing::Level::TRACE, "wit-bindgen export", module =975"foo:foo/flegs", function = "roundtrip-flag8",976);977let callee = unsafe {978wasmtime::component::TypedFunc::<979(Flag8,),980(Flag8,),981>::new_unchecked(self.roundtrip_flag8)982};983let (ret0,) = callee984.call_async(store.as_context_mut(), (arg0,))985.instrument(span.clone())986.await?;987Ok(ret0)988}989pub async fn call_roundtrip_flag16<S: wasmtime::AsContextMut>(990&self,991mut store: S,992arg0: Flag16,993) -> wasmtime::Result<Flag16>994where995<S as wasmtime::AsContext>::Data: Send,996{997use tracing::Instrument;998let span = tracing::span!(999tracing::Level::TRACE, "wit-bindgen export", module =1000"foo:foo/flegs", function = "roundtrip-flag16",1001);1002let callee = unsafe {1003wasmtime::component::TypedFunc::<1004(Flag16,),1005(Flag16,),1006>::new_unchecked(self.roundtrip_flag16)1007};1008let (ret0,) = callee1009.call_async(store.as_context_mut(), (arg0,))1010.instrument(span.clone())1011.await?;1012Ok(ret0)1013}1014pub async fn call_roundtrip_flag32<S: wasmtime::AsContextMut>(1015&self,1016mut store: S,1017arg0: Flag32,1018) -> wasmtime::Result<Flag32>1019where1020<S as wasmtime::AsContext>::Data: Send,1021{1022use tracing::Instrument;1023let span = tracing::span!(1024tracing::Level::TRACE, "wit-bindgen export", module =1025"foo:foo/flegs", function = "roundtrip-flag32",1026);1027let callee = unsafe {1028wasmtime::component::TypedFunc::<1029(Flag32,),1030(Flag32,),1031>::new_unchecked(self.roundtrip_flag32)1032};1033let (ret0,) = callee1034.call_async(store.as_context_mut(), (arg0,))1035.instrument(span.clone())1036.await?;1037Ok(ret0)1038}1039pub async fn call_roundtrip_flag64<S: wasmtime::AsContextMut>(1040&self,1041mut store: S,1042arg0: Flag64,1043) -> wasmtime::Result<Flag64>1044where1045<S as wasmtime::AsContext>::Data: Send,1046{1047use tracing::Instrument;1048let span = tracing::span!(1049tracing::Level::TRACE, "wit-bindgen export", module =1050"foo:foo/flegs", function = "roundtrip-flag64",1051);1052let callee = unsafe {1053wasmtime::component::TypedFunc::<1054(Flag64,),1055(Flag64,),1056>::new_unchecked(self.roundtrip_flag64)1057};1058let (ret0,) = callee1059.call_async(store.as_context_mut(), (arg0,))1060.instrument(span.clone())1061.await?;1062Ok(ret0)1063}1064}1065}1066}1067}1068}106910701071