summaryrefslogtreecommitdiff
path: root/cli/ops
diff options
context:
space:
mode:
Diffstat (limited to 'cli/ops')
-rw-r--r--cli/ops/dispatch_json.rs20
-rw-r--r--cli/ops/dispatch_minimal.rs12
2 files changed, 15 insertions, 17 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())
}
}
}