diff options
Diffstat (limited to 'cli')
-rw-r--r-- | cli/ops/dispatch_json.rs | 20 | ||||
-rw-r--r-- | cli/ops/dispatch_minimal.rs | 12 | ||||
-rw-r--r-- | cli/state.rs | 14 |
3 files changed, 21 insertions, 25 deletions
diff --git a/cli/ops/dispatch_json.rs b/cli/ops/dispatch_json.rs index 70498eb8f..b1a7bc723 100644 --- a/cli/ops/dispatch_json.rs +++ b/cli/ops/dispatch_json.rs @@ -41,7 +41,7 @@ struct AsyncArgs { promise_id: Option<u64>, } -pub fn json_op<D>(d: D) -> impl Fn(&[u8], Option<ZeroCopyBuf>) -> CoreOp +pub fn json_op<D>(d: D) -> impl Fn(&[u8], Option<ZeroCopyBuf>) -> Op where D: Fn(Value, Option<ZeroCopyBuf>) -> Result<JsonOp, OpError>, { @@ -50,7 +50,7 @@ where Ok(args) => args, Err(e) => { let buf = serialize_result(None, Err(OpError::from(e))); - return CoreOp::Sync(buf); + return Op::Sync(buf); } }; let promise_id = async_args.promise_id; @@ -60,32 +60,32 @@ where .map_err(OpError::from) .and_then(|args| d(args, zero_copy)); - // Convert to CoreOp + // Convert to Op match result { Ok(JsonOp::Sync(sync_value)) => { assert!(promise_id.is_none()); - CoreOp::Sync(serialize_result(promise_id, Ok(sync_value))) + Op::Sync(serialize_result(promise_id, Ok(sync_value))) } Ok(JsonOp::Async(fut)) => { assert!(promise_id.is_some()); let fut2 = fut.then(move |result| { - futures::future::ok(serialize_result(promise_id, result)) + futures::future::ready(serialize_result(promise_id, result)) }); - CoreOp::Async(fut2.boxed_local()) + Op::Async(fut2.boxed_local()) } Ok(JsonOp::AsyncUnref(fut)) => { assert!(promise_id.is_some()); let fut2 = fut.then(move |result| { - futures::future::ok(serialize_result(promise_id, result)) + futures::future::ready(serialize_result(promise_id, result)) }); - CoreOp::AsyncUnref(fut2.boxed_local()) + Op::AsyncUnref(fut2.boxed_local()) } Err(sync_err) => { let buf = serialize_result(promise_id, Err(sync_err)); if is_sync { - CoreOp::Sync(buf) + Op::Sync(buf) } else { - CoreOp::Async(futures::future::ok(buf).boxed_local()) + Op::Async(futures::future::ready(buf).boxed_local()) } } } diff --git a/cli/ops/dispatch_minimal.rs b/cli/ops/dispatch_minimal.rs index 299462ca0..7fdd12401 100644 --- a/cli/ops/dispatch_minimal.rs +++ b/cli/ops/dispatch_minimal.rs @@ -7,7 +7,6 @@ use crate::op_error::OpError; use byteorder::{LittleEndian, WriteBytesExt}; use deno_core::Buf; -use deno_core::CoreOp; use deno_core::Op; use deno_core::ZeroCopyBuf; use futures::future::FutureExt; @@ -114,7 +113,7 @@ fn test_parse_min_record() { assert_eq!(parse_min_record(&buf), None); } -pub fn minimal_op<D>(d: D) -> impl Fn(&[u8], Option<ZeroCopyBuf>) -> CoreOp +pub fn minimal_op<D>(d: D) -> impl Fn(&[u8], Option<ZeroCopyBuf>) -> Op where D: Fn(bool, i32, Option<ZeroCopyBuf>) -> MinimalOp, { @@ -153,12 +152,11 @@ where } }), MinimalOp::Async(min_fut) => { - // Convert to CoreOp - let core_fut = async move { + let fut = async move { match min_fut.await { Ok(r) => { record.result = r; - Ok(record.into()) + record.into() } Err(err) => { let error_record = ErrorRecord { @@ -167,11 +165,11 @@ where error_code: err.kind as i32, error_message: err.msg.as_bytes().to_owned(), }; - Ok(error_record.into()) + error_record.into() } } }; - Op::Async(core_fut.boxed_local()) + Op::Async(fut.boxed_local()) } } } diff --git a/cli/state.rs b/cli/state.rs index f67d5e9a6..82ac8c4c1 100644 --- a/cli/state.rs +++ b/cli/state.rs @@ -10,7 +10,6 @@ use crate::ops::MinimalOp; use crate::permissions::DenoPermissions; use crate::web_worker::WebWorkerHandle; use deno_core::Buf; -use deno_core::CoreOp; use deno_core::ErrBox; use deno_core::ModuleLoader; use deno_core::ModuleSpecifier; @@ -18,7 +17,6 @@ use deno_core::Op; use deno_core::ResourceTable; use deno_core::ZeroCopyBuf; use futures::future::FutureExt; -use futures::future::TryFutureExt; use rand::rngs::StdRng; use rand::SeedableRng; use serde_json::Value; @@ -75,7 +73,7 @@ impl State { pub fn stateful_json_op<D>( &self, dispatcher: D, - ) -> impl Fn(&[u8], Option<ZeroCopyBuf>) -> CoreOp + ) -> impl Fn(&[u8], Option<ZeroCopyBuf>) -> Op where D: Fn(&State, Value, Option<ZeroCopyBuf>) -> Result<JsonOp, OpError>, { @@ -87,13 +85,13 @@ impl State { pub fn core_op<D>( &self, dispatcher: D, - ) -> impl Fn(&[u8], Option<ZeroCopyBuf>) -> CoreOp + ) -> impl Fn(&[u8], Option<ZeroCopyBuf>) -> Op where - D: Fn(&[u8], Option<ZeroCopyBuf>) -> CoreOp, + D: Fn(&[u8], Option<ZeroCopyBuf>) -> Op, { let state = self.clone(); - move |control: &[u8], zero_copy: Option<ZeroCopyBuf>| -> CoreOp { + move |control: &[u8], zero_copy: Option<ZeroCopyBuf>| -> Op { let bytes_sent_control = control.len() as u64; let bytes_sent_zero_copy = zero_copy.as_ref().map(|b| b.len()).unwrap_or(0) as u64; @@ -116,7 +114,7 @@ impl State { .metrics .op_dispatched_async(bytes_sent_control, bytes_sent_zero_copy); let state = state.clone(); - let result_fut = fut.map_ok(move |buf: Buf| { + let result_fut = fut.map(move |buf: Buf| { let mut state_ = state.borrow_mut(); state_.metrics.op_completed_async(buf.len() as u64); buf @@ -130,7 +128,7 @@ impl State { bytes_sent_zero_copy, ); let state = state.clone(); - let result_fut = fut.map_ok(move |buf: Buf| { + let result_fut = fut.map(move |buf: Buf| { let mut state_ = state.borrow_mut(); state_.metrics.op_completed_async_unref(buf.len() as u64); buf |