Skip to content

Commit bbb4f9d

Browse files
committed
chore: adapt to stream API changes
Signed-off-by: Roman Volosatovs <[email protected]>
1 parent 7cc19b1 commit bbb4f9d

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

crates/wasi/src/p3/cli/host.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,15 @@ where
2525
{
2626
async fn run(mut self, store: &Accessor<T, U>) -> wasmtime::Result<()> {
2727
let mut buf = BytesMut::with_capacity(8192);
28-
let mut tx = self.tx;
29-
loop {
28+
while !self.tx.is_closed() {
3029
match self.rx.read_buf(&mut buf).await {
3130
Ok(0) => return Ok(()),
3231
Ok(_) => {
33-
let (Some(tx_next), buf_next) = tx.write_all(store, Cursor::new(buf)).await
34-
else {
35-
break Ok(());
36-
};
37-
tx = tx_next;
38-
buf = buf_next.into_inner();
32+
buf = self
33+
.tx
34+
.write_all(store, Cursor::new(buf))
35+
.await
36+
.into_inner();
3937
buf.clear();
4038
}
4139
Err(_err) => {
@@ -44,6 +42,7 @@ where
4442
}
4543
}
4644
}
45+
Ok(())
4746
}
4847
}
4948

@@ -59,10 +58,8 @@ where
5958
{
6059
async fn run(mut self, store: &Accessor<T, U>) -> wasmtime::Result<()> {
6160
let mut buf = BytesMut::with_capacity(8192);
62-
let mut rx = self.rx;
63-
while let (Some(rx_next), buf_next) = rx.read(store, buf).await {
64-
buf = buf_next;
65-
rx = rx_next;
61+
while !self.rx.is_closed() {
62+
buf = self.rx.read(store, buf).await;
6663
match self.tx.write_all(&buf).await {
6764
Ok(()) => {
6865
buf.clear();

0 commit comments

Comments
 (0)