summaryrefslogtreecommitdiff
path: root/core/ops_json.rs
diff options
context:
space:
mode:
authorAaron O'Mullan <aaron.omullan@gmail.com>2021-04-12 21:55:05 +0200
committerGitHub <noreply@github.com>2021-04-12 15:55:05 -0400
commit46b1c653c0c433932908b7610f60b409af134c76 (patch)
tree00d8b59c8c4e9b90538d548ebd828d2b3f94d4fd /core/ops_json.rs
parenta20504642d083172f297543f9788b128e9c2e0bc (diff)
refactor(deno): remove concept of bin & json ops (#10145)
Diffstat (limited to 'core/ops_json.rs')
-rw-r--r--core/ops_json.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/core/ops_json.rs b/core/ops_json.rs
index 3e2b532d0..cf2e6230b 100644
--- a/core/ops_json.rs
+++ b/core/ops_json.rs
@@ -25,18 +25,18 @@ use std::rc::Rc;
/// When registering an op like this...
/// ```ignore
/// let mut runtime = JsRuntime::new(...);
-/// runtime.register_op("hello", deno_core::json_op_sync(Self::hello_op));
+/// runtime.register_op("hello", deno_core::op_sync(Self::hello_op));
/// ```
///
/// ...it can be invoked from JS using the provided name, for example:
/// ```js
/// Deno.core.ops();
-/// let result = Deno.core.jsonOpSync("function_name", args);
+/// let result = Deno.core.opSync("function_name", args);
/// ```
///
/// The `Deno.core.ops()` statement is needed once before any op calls, for initialization.
/// A more complete example is available in the examples directory.
-pub fn json_op_sync<F, V, R>(op_fn: F) -> Box<OpFn>
+pub fn op_sync<F, V, R>(op_fn: F) -> Box<OpFn>
where
F: Fn(&mut OpState, V, Option<ZeroCopyBuf>) -> Result<R, AnyError> + 'static,
V: DeserializeOwned,
@@ -63,18 +63,18 @@ where
/// When registering an op like this...
/// ```ignore
/// let mut runtime = JsRuntime::new(...);
-/// runtime.register_op("hello", deno_core::json_op_async(Self::hello_op));
+/// runtime.register_op("hello", deno_core::op_async(Self::hello_op));
/// ```
///
/// ...it can be invoked from JS using the provided name, for example:
/// ```js
/// Deno.core.ops();
-/// let future = Deno.core.jsonOpAsync("function_name", args);
+/// let future = Deno.core.opAsync("function_name", args);
/// ```
///
/// The `Deno.core.ops()` statement is needed once before any op calls, for initialization.
/// A more complete example is available in the examples directory.
-pub fn json_op_async<F, V, R, RV>(op_fn: F) -> Box<OpFn>
+pub fn op_async<F, V, R, RV>(op_fn: F) -> Box<OpFn>
where
F: Fn(Rc<RefCell<OpState>>, V, Option<ZeroCopyBuf>) -> R + 'static,
V: DeserializeOwned,
@@ -115,7 +115,7 @@ mod tests {
use super::*;
#[tokio::test]
- async fn json_op_async_stack_trace() {
+ async fn op_async_stack_trace() {
let mut runtime = crate::JsRuntime::new(Default::default());
async fn op_throw(
@@ -128,7 +128,7 @@ mod tests {
Err(crate::error::generic_error("foo"))
}
- runtime.register_op("op_throw", json_op_async(op_throw));
+ runtime.register_op("op_throw", op_async(op_throw));
runtime
.execute(
"<init>",
@@ -139,7 +139,7 @@ mod tests {
Deno.core.registerErrorClass('Error', Error);
async function f1() {
- await Deno.core.jsonOpAsync('op_throw', 'hello');
+ await Deno.core.opAsync('op_throw', 'hello');
}
async function f2() {