summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2022-04-21 02:22:55 +0200
committerGitHub <noreply@github.com>2022-04-21 02:22:55 +0200
commit03019e778189b38938f1238f22652162de5a7434 (patch)
treecf16b44be07c1c488ffe4f31fe77eab7f6bd8c95 /core
parentaaaa877d91c5f8b88722fd1ec725791b0eb4efe0 (diff)
Revert various PRs related to "ext/http" (#14339)
* Revert "feat(ext/http): stream auto resp body compression (#14325)" * Revert "core: introduce `resource.read_return` (#14331)" * Revert "perf(http): optimize `ReadableStream`s backed by a resource (#14284)"
Diffstat (limited to 'core')
-rw-r--r--core/examples/http_bench_json_ops.rs16
-rw-r--r--core/resources.rs12
2 files changed, 5 insertions, 23 deletions
diff --git a/core/examples/http_bench_json_ops.rs b/core/examples/http_bench_json_ops.rs
index 7c895f326..2068c3b85 100644
--- a/core/examples/http_bench_json_ops.rs
+++ b/core/examples/http_bench_json_ops.rs
@@ -83,18 +83,13 @@ struct TcpStream {
}
impl TcpStream {
- async fn read(
- self: Rc<Self>,
- mut buf: ZeroCopyBuf,
- ) -> Result<(usize, ZeroCopyBuf), Error> {
+ async fn read(self: Rc<Self>, mut buf: ZeroCopyBuf) -> Result<usize, Error> {
let mut rd = RcRef::map(&self, |r| &r.rd).borrow_mut().await;
let cancel = RcRef::map(self, |r| &r.cancel);
- let nread = rd
- .read(&mut buf)
+ rd.read(&mut buf)
.try_or_cancel(cancel)
.await
- .map_err(Error::from)?;
- Ok((nread, buf))
+ .map_err(Error::from)
}
async fn write(self: Rc<Self>, buf: ZeroCopyBuf) -> Result<usize, Error> {
@@ -104,10 +99,7 @@ impl TcpStream {
}
impl Resource for TcpStream {
- fn read_return(
- self: Rc<Self>,
- buf: ZeroCopyBuf,
- ) -> AsyncResult<(usize, ZeroCopyBuf)> {
+ fn read(self: Rc<Self>, buf: ZeroCopyBuf) -> AsyncResult<usize> {
Box::pin(self.read(buf))
}
diff --git a/core/resources.rs b/core/resources.rs
index ae4ef7394..9a1447392 100644
--- a/core/resources.rs
+++ b/core/resources.rs
@@ -36,17 +36,7 @@ pub trait Resource: Any + 'static {
}
/// 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)
- })
- }
-
- fn read_return(
- self: Rc<Self>,
- _buf: ZeroCopyBuf,
- ) -> AsyncResult<(usize, ZeroCopyBuf)> {
+ fn read(self: Rc<Self>, _buf: ZeroCopyBuf) -> AsyncResult<usize> {
Box::pin(futures::future::err(not_supported()))
}