summaryrefslogtreecommitdiff
path: root/ext/net/io.rs
diff options
context:
space:
mode:
Diffstat (limited to 'ext/net/io.rs')
-rw-r--r--ext/net/io.rs16
1 files changed, 11 insertions, 5 deletions
diff --git a/ext/net/io.rs b/ext/net/io.rs
index 17b86af17..02caf7473 100644
--- a/ext/net/io.rs
+++ b/ext/net/io.rs
@@ -70,13 +70,13 @@ where
pub async fn read(
self: Rc<Self>,
mut buf: ZeroCopyBuf,
- ) -> Result<usize, AnyError> {
+ ) -> Result<(usize, ZeroCopyBuf), AnyError> {
let mut rd = self.rd_borrow_mut().await;
let nread = rd
.read(&mut buf)
.try_or_cancel(self.cancel_handle())
.await?;
- Ok(nread)
+ Ok((nread, buf))
}
pub async fn write(
@@ -103,7 +103,10 @@ impl Resource for TcpStreamResource {
"tcpStream".into()
}
- fn read(self: Rc<Self>, buf: ZeroCopyBuf) -> AsyncResult<usize> {
+ fn read_return(
+ self: Rc<Self>,
+ buf: ZeroCopyBuf,
+ ) -> AsyncResult<(usize, ZeroCopyBuf)> {
Box::pin(self.read(buf))
}
@@ -160,7 +163,7 @@ impl UnixStreamResource {
pub async fn read(
self: Rc<Self>,
_buf: ZeroCopyBuf,
- ) -> Result<usize, AnyError> {
+ ) -> Result<(usize, ZeroCopyBuf), AnyError> {
unreachable!()
}
pub async fn write(
@@ -182,7 +185,10 @@ impl Resource for UnixStreamResource {
"unixStream".into()
}
- fn read(self: Rc<Self>, buf: ZeroCopyBuf) -> AsyncResult<usize> {
+ fn read_return(
+ self: Rc<Self>,
+ buf: ZeroCopyBuf,
+ ) -> AsyncResult<(usize, ZeroCopyBuf)> {
Box::pin(self.read(buf))
}