summaryrefslogtreecommitdiff
path: root/core/examples/http_bench_json_ops.rs
diff options
context:
space:
mode:
Diffstat (limited to 'core/examples/http_bench_json_ops.rs')
-rw-r--r--core/examples/http_bench_json_ops.rs20
1 files changed, 10 insertions, 10 deletions
diff --git a/core/examples/http_bench_json_ops.rs b/core/examples/http_bench_json_ops.rs
index b1116d757..cb3c64945 100644
--- a/core/examples/http_bench_json_ops.rs
+++ b/core/examples/http_bench_json_ops.rs
@@ -1,8 +1,8 @@
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
use deno_core::error::bad_resource_id;
+use deno_core::error::null_opbuf;
use deno_core::error::AnyError;
use deno_core::AsyncRefCell;
-use deno_core::BufVec;
use deno_core::CancelHandle;
use deno_core::CancelTryFuture;
use deno_core::JsRuntime;
@@ -122,7 +122,7 @@ fn create_js_runtime() -> JsRuntime {
fn op_listen(
state: &mut OpState,
_args: (),
- _bufs: &mut [ZeroCopyBuf],
+ _bufs: Option<ZeroCopyBuf>,
) -> Result<ResourceId, AnyError> {
log::debug!("listen");
let addr = "127.0.0.1:4544".parse::<SocketAddr>().unwrap();
@@ -136,7 +136,7 @@ fn op_listen(
fn op_close(
state: &mut OpState,
rid: ResourceId,
- _buf: &mut [ZeroCopyBuf],
+ _buf: Option<ZeroCopyBuf>,
) -> Result<(), AnyError> {
log::debug!("close rid={}", rid);
state
@@ -149,7 +149,7 @@ fn op_close(
async fn op_accept(
state: Rc<RefCell<OpState>>,
rid: ResourceId,
- _bufs: BufVec,
+ _buf: Option<ZeroCopyBuf>,
) -> Result<ResourceId, AnyError> {
log::debug!("accept rid={}", rid);
@@ -166,9 +166,9 @@ async fn op_accept(
async fn op_read(
state: Rc<RefCell<OpState>>,
rid: ResourceId,
- mut bufs: BufVec,
+ buf: Option<ZeroCopyBuf>,
) -> Result<usize, AnyError> {
- assert_eq!(bufs.len(), 1, "Invalid number of arguments");
+ let mut buf = buf.ok_or_else(null_opbuf)?;
log::debug!("read rid={}", rid);
let stream = state
@@ -176,16 +176,16 @@ async fn op_read(
.resource_table
.get::<TcpStream>(rid)
.ok_or_else(bad_resource_id)?;
- let nread = stream.read(&mut bufs[0]).await?;
+ let nread = stream.read(&mut buf).await?;
Ok(nread)
}
async fn op_write(
state: Rc<RefCell<OpState>>,
rid: ResourceId,
- bufs: BufVec,
+ buf: Option<ZeroCopyBuf>,
) -> Result<usize, AnyError> {
- assert_eq!(bufs.len(), 1, "Invalid number of arguments");
+ let buf = buf.ok_or_else(null_opbuf)?;
log::debug!("write rid={}", rid);
let stream = state
@@ -193,7 +193,7 @@ async fn op_write(
.resource_table
.get::<TcpStream>(rid)
.ok_or_else(bad_resource_id)?;
- let nwritten = stream.write(&bufs[0]).await?;
+ let nwritten = stream.write(&buf).await?;
Ok(nwritten)
}