From 77a00ce1fb4ae2523e22b9b84ae09a0200502e38 Mon Sep 17 00:00:00 2001 From: Leo K Date: Tue, 5 Oct 2021 22:38:27 +0200 Subject: chore: various op cleanup (#12329) --- core/error.rs | 4 ---- core/examples/http_bench_json_ops.rs | 9 +++------ core/ops_builtin.rs | 2 +- core/runtime.rs | 6 +----- 4 files changed, 5 insertions(+), 16 deletions(-) (limited to 'core') diff --git a/core/error.rs b/core/error.rs index 087b27c41..be97a90fb 100644 --- a/core/error.rs +++ b/core/error.rs @@ -67,10 +67,6 @@ pub fn resource_unavailable() -> AnyError { ) } -pub fn null_opbuf() -> AnyError { - type_error("expected non-null op buffer arg") -} - /// A simple error type that lets the creator specify both the error message and /// the error class name. This type is private; externally it only ever appears /// wrapped in an `AnyError`. To retrieve the error class name from a wrapped diff --git a/core/examples/http_bench_json_ops.rs b/core/examples/http_bench_json_ops.rs index d273c2c88..5989a472f 100644 --- a/core/examples/http_bench_json_ops.rs +++ b/core/examples/http_bench_json_ops.rs @@ -1,5 +1,4 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. -use deno_core::error::null_opbuf; use deno_core::error::AnyError; use deno_core::AsyncRefCell; use deno_core::CancelHandle; @@ -121,7 +120,7 @@ fn create_js_runtime() -> JsRuntime { fn op_listen( state: &mut OpState, - _args: (), + _: (), _: (), ) -> Result { log::debug!("listen"); @@ -158,9 +157,8 @@ async fn op_accept( async fn op_read( state: Rc>, rid: ResourceId, - buf: Option, + mut buf: ZeroCopyBuf, ) -> Result { - let mut buf = buf.ok_or_else(null_opbuf)?; log::debug!("read rid={}", rid); let stream = state.borrow().resource_table.get::(rid)?; @@ -171,9 +169,8 @@ async fn op_read( async fn op_write( state: Rc>, rid: ResourceId, - buf: Option, + buf: ZeroCopyBuf, ) -> Result { - let buf = buf.ok_or_else(null_opbuf)?; log::debug!("write rid={}", rid); let stream = state.borrow().resource_table.get::(rid)?; diff --git a/core/ops_builtin.rs b/core/ops_builtin.rs index e1313fa32..392062960 100644 --- a/core/ops_builtin.rs +++ b/core/ops_builtin.rs @@ -34,7 +34,7 @@ pub(crate) fn init_builtins() -> Extension { /// and string representation as value. pub fn op_resources( state: &mut OpState, - _args: (), + _: (), _: (), ) -> Result, AnyError> { let serialized_resources = state diff --git a/core/runtime.rs b/core/runtime.rs index 305052e9a..e4fe8cd6c 100644 --- a/core/runtime.rs +++ b/core/runtime.rs @@ -1919,11 +1919,7 @@ pub mod tests { #[test] fn test_error_builder() { - fn op_err( - _: &mut OpState, - _: (), - _: Option, - ) -> Result<(), AnyError> { + fn op_err(_: &mut OpState, _: (), _: ()) -> Result<(), AnyError> { Err(custom_error("DOMExceptionOperationError", "abc")) } -- cgit v1.2.3