@@ -10,7 +10,7 @@ use bytes::BytesMut;
1010use std:: io:: Cursor ;
1111use tokio:: io:: { AsyncRead , AsyncReadExt as _, AsyncWrite , AsyncWriteExt as _} ;
1212use wasmtime:: component:: {
13- Accessor , AccessorTask , HasData , HostStream , Resource , StreamReader , StreamWriter ,
13+ Accessor , AccessorTask , HasData , Resource , StreamReader , StreamWriter , WithAccessor ,
1414} ;
1515
1616struct InputTask < T > {
@@ -24,16 +24,13 @@ where
2424 V : AsyncRead + Send + Sync + Unpin + ' static ,
2525{
2626 async fn run ( mut self , store : & Accessor < T , U > ) -> wasmtime:: Result < ( ) > {
27+ let mut tx = WithAccessor :: new ( store, self . tx ) ;
2728 let mut buf = BytesMut :: with_capacity ( 8192 ) ;
28- while !self . tx . is_closed ( ) {
29+ while !tx. is_closed ( ) {
2930 match self . rx . read_buf ( & mut buf) . await {
3031 Ok ( 0 ) => return Ok ( ( ) ) ,
3132 Ok ( _) => {
32- buf = self
33- . tx
34- . write_all ( store, Cursor :: new ( buf) )
35- . await
36- . into_inner ( ) ;
33+ buf = tx. write_all ( store, Cursor :: new ( buf) ) . await . into_inner ( ) ;
3734 buf. clear ( ) ;
3835 }
3936 Err ( _err) => {
5754 V : AsyncWrite + Send + Sync + Unpin + ' static ,
5855{
5956 async fn run ( mut self , store : & Accessor < T , U > ) -> wasmtime:: Result < ( ) > {
57+ let mut rx = WithAccessor :: new ( store, self . rx ) ;
6058 let mut buf = BytesMut :: with_capacity ( 8192 ) ;
61- while !self . rx . is_closed ( ) {
62- buf = self . rx . read ( store, buf) . await ;
59+ while !rx. is_closed ( ) {
60+ buf = rx. read ( store, buf) . await ;
6361 match self . tx . write_all ( & buf) . await {
6462 Ok ( ( ) ) => {
6563 buf. clear ( ) ;
0 commit comments