summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorLuca Casonato <hello@lcas.dev>2022-09-30 07:54:12 +0200
committerGitHub <noreply@github.com>2022-09-30 07:54:12 +0200
commit20c7300412bdb487fc758577d6256bbcf96efd12 (patch)
tree2dcd218a6095a2ad143fb27e304391b5fe64cf27 /core
parent38f544538b337074cbce317e67859a69bb23684c (diff)
refactor(ext/http): remove op_http_read (#16096)
We can use Resource::read_return & op_read instead. This allows HTTP request bodies to participate in FastStream. To make this work, `readableStreamForRid` required a change to allow non auto-closing resources to be handled. This required some minor changes in our FastStream paths in ext/http and ext/flash.
Diffstat (limited to 'core')
-rw-r--r--core/ops_builtin.rs2
-rw-r--r--core/resources.rs9
2 files changed, 2 insertions, 9 deletions
diff --git a/core/ops_builtin.rs b/core/ops_builtin.rs
index 02ecabc9c..6ca2a132c 100644
--- a/core/ops_builtin.rs
+++ b/core/ops_builtin.rs
@@ -165,7 +165,7 @@ async fn op_read(
buf: ZeroCopyBuf,
) -> Result<u32, Error> {
let resource = state.borrow().resource_table.get_any(rid)?;
- resource.read(buf).await.map(|n| n as u32)
+ resource.read_return(buf).await.map(|(n, _)| n as u32)
}
#[op]
diff --git a/core/resources.rs b/core/resources.rs
index eaa1fb3cf..56c9298af 100644
--- a/core/resources.rs
+++ b/core/resources.rs
@@ -35,14 +35,7 @@ pub trait Resource: Any + 'static {
type_name::<Self>().into()
}
- /// Resources may implement `read()` to be a readable stream
- fn read(self: Rc<Self>, buf: ZeroCopyBuf) -> AsyncResult<usize> {
- Box::pin(async move {
- let (nread, _) = self.read_return(buf).await?;
- Ok(nread)
- })
- }
-
+ /// Resources may implement `read_return()` to be a readable stream
fn read_return(
self: Rc<Self>,
_buf: ZeroCopyBuf,