summaryrefslogtreecommitdiff
path: root/runtime/ops/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/ops/mod.rs')
-rw-r--r--runtime/ops/mod.rs27
1 files changed, 24 insertions, 3 deletions
diff --git a/runtime/ops/mod.rs b/runtime/ops/mod.rs
index 6b64b8042..e082c5d3a 100644
--- a/runtime/ops/mod.rs
+++ b/runtime/ops/mod.rs
@@ -1,8 +1,5 @@
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
-mod dispatch_minimal;
-pub use dispatch_minimal::MinimalOp;
-
pub mod crypto;
pub mod fetch;
pub mod fs;
@@ -11,6 +8,7 @@ pub mod io;
pub mod net;
#[cfg(unix)]
mod net_unix;
+mod ops_buffer;
pub mod os;
pub mod permissions;
pub mod plugin;
@@ -36,6 +34,9 @@ use deno_core::BufVec;
use deno_core::JsRuntime;
use deno_core::OpState;
use deno_core::ZeroCopyBuf;
+use ops_buffer::buffer_op_async;
+use ops_buffer::buffer_op_sync;
+use ops_buffer::ValueOrVector;
use std::cell::RefCell;
use std::future::Future;
use std::rc::Rc;
@@ -62,6 +63,26 @@ where
rt.register_op(name, metrics_op(name, json_op_sync(op_fn)));
}
+pub fn reg_buffer_async<F, R, RV>(
+ rt: &mut JsRuntime,
+ name: &'static str,
+ op_fn: F,
+) where
+ F: Fn(Rc<RefCell<OpState>>, u32, BufVec) -> R + 'static,
+ R: Future<Output = Result<RV, AnyError>> + 'static,
+ RV: ValueOrVector,
+{
+ rt.register_op(name, metrics_op(name, buffer_op_async(op_fn)));
+}
+
+pub fn reg_buffer_sync<F, R>(rt: &mut JsRuntime, name: &'static str, op_fn: F)
+where
+ F: Fn(&mut OpState, u32, &mut [ZeroCopyBuf]) -> Result<R, AnyError> + 'static,
+ R: ValueOrVector,
+{
+ rt.register_op(name, metrics_op(name, buffer_op_sync(op_fn)));
+}
+
/// `UnstableChecker` is a struct so it can be placed inside `GothamState`;
/// using type alias for a bool could work, but there's a high chance
/// that there might be another type alias pointing to a bool, which