11pub enum WorldResource { }
22pub trait HostWorldResourceWithStore : wasmtime:: component:: HasData + Send {
3+ fn drop < T : ' static > (
4+ accessor : & wasmtime:: component:: Accessor < T , Self > ,
5+ rep : wasmtime:: component:: Resource < WorldResource > ,
6+ ) -> impl :: core:: future:: Future < Output = wasmtime:: Result < ( ) > > + Send
7+ where
8+ Self : Sized ;
39 fn new < T : ' static > (
410 accessor : & wasmtime:: component:: Accessor < T , Self > ,
511 ) -> impl :: core:: future:: Future <
@@ -13,20 +19,8 @@ pub trait HostWorldResourceWithStore: wasmtime::component::HasData + Send {
1319 accessor : & wasmtime:: component:: Accessor < T , Self > ,
1420 ) -> impl :: core:: future:: Future < Output = ( ) > + Send ;
1521}
16- pub trait HostWorldResource : Send {
17- fn drop (
18- & mut self ,
19- rep : wasmtime:: component:: Resource < WorldResource > ,
20- ) -> impl :: core:: future:: Future < Output = wasmtime:: Result < ( ) > > + Send ;
21- }
22- impl < _T : HostWorldResource + ?Sized + Send > HostWorldResource for & mut _T {
23- async fn drop (
24- & mut self ,
25- rep : wasmtime:: component:: Resource < WorldResource > ,
26- ) -> wasmtime:: Result < ( ) > {
27- HostWorldResource :: drop ( * self , rep) . await
28- }
29- }
22+ pub trait HostWorldResource : Send { }
23+ impl < _T : HostWorldResource + ?Sized + Send > HostWorldResource for & mut _T { }
3024/// Auto-generated bindings for a pre-instantiated version of a
3125/// component which implements the world `the-world`.
3226///
@@ -260,13 +254,14 @@ const _: () = {
260254 {
261255 let mut linker = linker. root ( ) ;
262256 linker
263- . resource_async (
257+ . resource_concurrent (
264258 "world-resource" ,
265259 wasmtime:: component:: ResourceType :: host :: < WorldResource > ( ) ,
266- move |mut store, rep| {
267- wasmtime:: component:: __internal:: Box :: new ( async move {
268- HostWorldResource :: drop (
269- & mut host_getter ( store. data_mut ( ) ) ,
260+ move |caller : & wasmtime:: component:: Accessor < T > , rep| {
261+ wasmtime:: component:: __internal:: Box :: pin ( async move {
262+ let accessor = & caller. with_data ( host_getter) ;
263+ HostWorldResourceWithStore :: drop (
264+ accessor,
270265 wasmtime:: component:: Resource :: new_own ( rep) ,
271266 )
272267 . await
@@ -398,6 +393,12 @@ pub mod foo {
398393 use wasmtime:: component:: __internal:: { anyhow, Box } ;
399394 pub enum Bar { }
400395 pub trait HostBarWithStore : wasmtime:: component:: HasData + Send {
396+ fn drop < T : ' static > (
397+ accessor : & wasmtime:: component:: Accessor < T , Self > ,
398+ rep : wasmtime:: component:: Resource < Bar > ,
399+ ) -> impl :: core:: future:: Future < Output = wasmtime:: Result < ( ) > > + Send
400+ where
401+ Self : Sized ;
401402 fn new < T : ' static > (
402403 accessor : & wasmtime:: component:: Accessor < T , Self > ,
403404 ) -> impl :: core:: future:: Future <
@@ -411,20 +412,8 @@ pub mod foo {
411412 self_ : wasmtime:: component:: Resource < Bar > ,
412413 ) -> impl :: core:: future:: Future < Output = u32 > + Send ;
413414 }
414- pub trait HostBar : Send {
415- fn drop (
416- & mut self ,
417- rep : wasmtime:: component:: Resource < Bar > ,
418- ) -> impl :: core:: future:: Future < Output = wasmtime:: Result < ( ) > > + Send ;
419- }
420- impl < _T : HostBar + ?Sized + Send > HostBar for & mut _T {
421- async fn drop (
422- & mut self ,
423- rep : wasmtime:: component:: Resource < Bar > ,
424- ) -> wasmtime:: Result < ( ) > {
425- HostBar :: drop ( * self , rep) . await
426- }
427- }
415+ pub trait HostBar : Send { }
416+ impl < _T : HostBar + ?Sized + Send > HostBar for & mut _T { }
428417 #[ derive( wasmtime:: component:: ComponentType ) ]
429418 #[ derive( wasmtime:: component:: Lift ) ]
430419 #[ derive( wasmtime:: component:: Lower ) ]
@@ -580,13 +569,14 @@ pub mod foo {
580569 T : ' static + Send ,
581570 {
582571 let mut inst = linker. instance ( "foo:foo/resources" ) ?;
583- inst. resource_async (
572+ inst. resource_concurrent (
584573 "bar" ,
585574 wasmtime:: component:: ResourceType :: host :: < Bar > ( ) ,
586- move |mut store, rep| {
587- wasmtime:: component:: __internal:: Box :: new ( async move {
588- HostBar :: drop (
589- & mut host_getter ( store. data_mut ( ) ) ,
575+ move |caller : & wasmtime:: component:: Accessor < T > , rep| {
576+ wasmtime:: component:: __internal:: Box :: pin ( async move {
577+ let accessor = & caller. with_data ( host_getter) ;
578+ HostBarWithStore :: drop (
579+ accessor,
590580 wasmtime:: component:: Resource :: new_own ( rep) ,
591581 )
592582 . await
@@ -904,25 +894,16 @@ pub mod foo {
904894 #[ allow( unused_imports) ]
905895 use wasmtime:: component:: __internal:: { anyhow, Box } ;
906896 pub enum A { }
907- pub trait HostAWithStore : wasmtime:: component:: HasData { }
908- impl < _T : ?Sized > HostAWithStore for _T
909- where
910- _T : wasmtime:: component:: HasData ,
911- { }
912- pub trait HostA {
913- fn drop (
914- & mut self ,
915- rep : wasmtime:: component:: Resource < A > ,
916- ) -> impl :: core:: future:: Future < Output = wasmtime:: Result < ( ) > > + Send ;
917- }
918- impl < _T : HostA + ?Sized + Send > HostA for & mut _T {
919- async fn drop (
920- & mut self ,
897+ pub trait HostAWithStore : wasmtime:: component:: HasData {
898+ fn drop < T : ' static > (
899+ accessor : & wasmtime:: component:: Accessor < T , Self > ,
921900 rep : wasmtime:: component:: Resource < A > ,
922- ) -> wasmtime:: Result < ( ) > {
923- HostA :: drop ( * self , rep ) . await
924- }
901+ ) -> impl :: core :: future :: Future < Output = wasmtime:: Result < ( ) > > + Send
902+ where
903+ Self : Sized ;
925904 }
905+ pub trait HostA { }
906+ impl < _T : HostA + ?Sized + Send > HostA for & mut _T { }
926907 pub trait HostWithStore : wasmtime:: component:: HasData + HostAWithStore + Send { }
927908 impl < _T : ?Sized > HostWithStore for _T
928909 where
@@ -940,13 +921,14 @@ pub mod foo {
940921 T : ' static + Send ,
941922 {
942923 let mut inst = linker. instance ( "foo:foo/long-use-chain1" ) ?;
943- inst. resource_async (
924+ inst. resource_concurrent (
944925 "a" ,
945926 wasmtime:: component:: ResourceType :: host :: < A > ( ) ,
946- move |mut store, rep| {
947- wasmtime:: component:: __internal:: Box :: new ( async move {
948- HostA :: drop (
949- & mut host_getter ( store. data_mut ( ) ) ,
927+ move |caller : & wasmtime:: component:: Accessor < T > , rep| {
928+ wasmtime:: component:: __internal:: Box :: pin ( async move {
929+ let accessor = & caller. with_data ( host_getter) ;
930+ HostAWithStore :: drop (
931+ accessor,
950932 wasmtime:: component:: Resource :: new_own ( rep) ,
951933 )
952934 . await
@@ -1048,25 +1030,16 @@ pub mod foo {
10481030 #[ allow( unused_imports) ]
10491031 use wasmtime:: component:: __internal:: { anyhow, Box } ;
10501032 pub enum Foo { }
1051- pub trait HostFooWithStore : wasmtime:: component:: HasData { }
1052- impl < _T : ?Sized > HostFooWithStore for _T
1053- where
1054- _T : wasmtime:: component:: HasData ,
1055- { }
1056- pub trait HostFoo {
1057- fn drop (
1058- & mut self ,
1059- rep : wasmtime:: component:: Resource < Foo > ,
1060- ) -> impl :: core:: future:: Future < Output = wasmtime:: Result < ( ) > > + Send ;
1061- }
1062- impl < _T : HostFoo + ?Sized + Send > HostFoo for & mut _T {
1063- async fn drop (
1064- & mut self ,
1033+ pub trait HostFooWithStore : wasmtime:: component:: HasData {
1034+ fn drop < T : ' static > (
1035+ accessor : & wasmtime:: component:: Accessor < T , Self > ,
10651036 rep : wasmtime:: component:: Resource < Foo > ,
1066- ) -> wasmtime:: Result < ( ) > {
1067- HostFoo :: drop ( * self , rep ) . await
1068- }
1037+ ) -> impl :: core :: future :: Future < Output = wasmtime:: Result < ( ) > > + Send
1038+ where
1039+ Self : Sized ;
10691040 }
1041+ pub trait HostFoo { }
1042+ impl < _T : HostFoo + ?Sized + Send > HostFoo for & mut _T { }
10701043 pub trait HostWithStore : wasmtime:: component:: HasData + HostFooWithStore + Send { }
10711044 impl < _T : ?Sized > HostWithStore for _T
10721045 where
@@ -1085,13 +1058,14 @@ pub mod foo {
10851058 {
10861059 let mut inst = linker
10871060 . instance ( "foo:foo/transitive-interface-with-resource" ) ?;
1088- inst. resource_async (
1061+ inst. resource_concurrent (
10891062 "foo" ,
10901063 wasmtime:: component:: ResourceType :: host :: < Foo > ( ) ,
1091- move |mut store, rep| {
1092- wasmtime:: component:: __internal:: Box :: new ( async move {
1093- HostFoo :: drop (
1094- & mut host_getter ( store. data_mut ( ) ) ,
1064+ move |caller : & wasmtime:: component:: Accessor < T > , rep| {
1065+ wasmtime:: component:: __internal:: Box :: pin ( async move {
1066+ let accessor = & caller. with_data ( host_getter) ;
1067+ HostFooWithStore :: drop (
1068+ accessor,
10951069 wasmtime:: component:: Resource :: new_own ( rep) ,
10961070 )
10971071 . await
@@ -1143,7 +1117,7 @@ pub mod exports {
11431117 . ok_or_else ( || {
11441118 anyhow:: anyhow!(
11451119 "instance export `foo:foo/uses-resource-transitively` does \
1146- not have export `{name}`"
1120+ not have export `{name}`"
11471121 )
11481122 } )
11491123 } ;
0 commit comments