summaryrefslogtreecommitdiff
path: root/core/examples/http_bench_json_ops.rs
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2021-11-16 09:02:28 -0500
committerGitHub <noreply@github.com>2021-11-16 09:02:28 -0500
commitb2036a4db71afd67a78f932528143fb07faea538 (patch)
treea78612e8868609af7aa6fe9ecf49d3ab0c42c9da /core/examples/http_bench_json_ops.rs
parentf9f9ddc5e308809343bbf5c07d4487df5a1b93cf (diff)
refactor: re-export anyhow from deno_core (#12777)
Diffstat (limited to 'core/examples/http_bench_json_ops.rs')
-rw-r--r--core/examples/http_bench_json_ops.rs26
1 files changed, 9 insertions, 17 deletions
diff --git a/core/examples/http_bench_json_ops.rs b/core/examples/http_bench_json_ops.rs
index 6f14f558c..641483b0b 100644
--- a/core/examples/http_bench_json_ops.rs
+++ b/core/examples/http_bench_json_ops.rs
@@ -1,5 +1,5 @@
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
-use deno_core::error::AnyError;
+use deno_core::anyhow::Error;
use deno_core::AsyncRefCell;
use deno_core::AsyncResult;
use deno_core::CancelHandle;
@@ -12,7 +12,6 @@ use deno_core::ResourceId;
use deno_core::ZeroCopyBuf;
use std::cell::RefCell;
use std::env;
-use std::io::Error;
use std::net::SocketAddr;
use std::rc::Rc;
use tokio::io::AsyncReadExt;
@@ -43,7 +42,7 @@ struct TcpListener {
}
impl TcpListener {
- async fn accept(self: Rc<Self>) -> Result<TcpStream, Error> {
+ async fn accept(self: Rc<Self>) -> Result<TcpStream, std::io::Error> {
let cancel = RcRef::map(&self, |r| &r.cancel);
let stream = self.inner.accept().try_or_cancel(cancel).await?.0.into();
Ok(stream)
@@ -57,7 +56,7 @@ impl Resource for TcpListener {
}
impl TryFrom<std::net::TcpListener> for TcpListener {
- type Error = Error;
+ type Error = std::io::Error;
fn try_from(
std_listener: std::net::TcpListener,
) -> Result<Self, Self::Error> {
@@ -78,21 +77,18 @@ struct TcpStream {
}
impl TcpStream {
- async fn read(
- self: Rc<Self>,
- mut buf: ZeroCopyBuf,
- ) -> Result<usize, AnyError> {
+ 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);
rd.read(&mut buf)
.try_or_cancel(cancel)
.await
- .map_err(AnyError::from)
+ .map_err(Error::from)
}
- async fn write(self: Rc<Self>, buf: ZeroCopyBuf) -> Result<usize, AnyError> {
+ async fn write(self: Rc<Self>, buf: ZeroCopyBuf) -> Result<usize, Error> {
let mut wr = RcRef::map(self, |r| &r.wr).borrow_mut().await;
- wr.write(&buf).await.map_err(AnyError::from)
+ wr.write(&buf).await.map_err(Error::from)
}
}
@@ -129,11 +125,7 @@ fn create_js_runtime() -> JsRuntime {
runtime
}
-fn op_listen(
- state: &mut OpState,
- _: (),
- _: (),
-) -> Result<ResourceId, AnyError> {
+fn op_listen(state: &mut OpState, _: (), _: ()) -> Result<ResourceId, Error> {
log::debug!("listen");
let addr = "127.0.0.1:4544".parse::<SocketAddr>().unwrap();
let std_listener = std::net::TcpListener::bind(&addr)?;
@@ -147,7 +139,7 @@ async fn op_accept(
state: Rc<RefCell<OpState>>,
rid: ResourceId,
_: (),
-) -> Result<ResourceId, AnyError> {
+) -> Result<ResourceId, Error> {
log::debug!("accept rid={}", rid);
let listener = state.borrow().resource_table.get::<TcpListener>(rid)?;