summaryrefslogtreecommitdiff
path: root/ext/fetch/lib.rs
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2022-04-20 22:09:13 +0530
committerGitHub <noreply@github.com>2022-04-20 18:39:13 +0200
commit2612b6f20fc21fb92402aa9086d13a7192ae3814 (patch)
tree59db7a916a2c8ad55000b152912fd4019f75121d /ext/fetch/lib.rs
parent57a8fc37fc99491fa2559694f78af52a597bc501 (diff)
core: introduce `resource.read_return` (#14331)
Diffstat (limited to 'ext/fetch/lib.rs')
-rw-r--r--ext/fetch/lib.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/ext/fetch/lib.rs b/ext/fetch/lib.rs
index c216d53fa..def823d8f 100644
--- a/ext/fetch/lib.rs
+++ b/ext/fetch/lib.rs
@@ -485,12 +485,15 @@ impl Resource for FetchResponseBodyResource {
"fetchResponseBody".into()
}
- fn read(self: Rc<Self>, mut buf: ZeroCopyBuf) -> AsyncResult<usize> {
+ fn read_return(
+ self: Rc<Self>,
+ mut buf: ZeroCopyBuf,
+ ) -> AsyncResult<(usize, ZeroCopyBuf)> {
Box::pin(async move {
let mut reader = RcRef::map(&self, |r| &r.reader).borrow_mut().await;
let cancel = RcRef::map(self, |r| &r.cancel);
let read = reader.read(&mut buf).try_or_cancel(cancel).await?;
- Ok(read)
+ Ok((read, buf))
})
}