diff options
Diffstat (limited to 'cli')
-rw-r--r-- | cli/ops/dispatch_json.rs | 5 | ||||
-rw-r--r-- | cli/ops/dispatch_minimal.rs | 5 | ||||
-rw-r--r-- | cli/ops/plugin.rs | 3 | ||||
-rw-r--r-- | cli/state.rs | 26 |
4 files changed, 12 insertions, 27 deletions
diff --git a/cli/ops/dispatch_json.rs b/cli/ops/dispatch_json.rs index 26ffc7d33..30a3a4433 100644 --- a/cli/ops/dispatch_json.rs +++ b/cli/ops/dispatch_json.rs @@ -3,6 +3,7 @@ use crate::op_error::OpError; use deno_core::Buf; use deno_core::CoreIsolateState; use deno_core::Op; +use deno_core::OpDispatcher; use deno_core::ZeroCopyBuf; use futures::future::FutureExt; pub use serde_derive::Deserialize; @@ -44,9 +45,7 @@ struct AsyncArgs { promise_id: Option<u64>, } -pub fn json_op<D>( - d: D, -) -> impl Fn(&mut CoreIsolateState, &mut [ZeroCopyBuf]) -> Op +pub fn json_op<D>(d: D) -> impl OpDispatcher where D: Fn( &mut CoreIsolateState, diff --git a/cli/ops/dispatch_minimal.rs b/cli/ops/dispatch_minimal.rs index 45b90ef81..c37e57e45 100644 --- a/cli/ops/dispatch_minimal.rs +++ b/cli/ops/dispatch_minimal.rs @@ -9,6 +9,7 @@ use byteorder::{LittleEndian, WriteBytesExt}; use deno_core::Buf; use deno_core::CoreIsolateState; use deno_core::Op; +use deno_core::OpDispatcher; use deno_core::ZeroCopyBuf; use futures::future::FutureExt; use std::future::Future; @@ -114,9 +115,7 @@ fn test_parse_min_record() { assert_eq!(parse_min_record(&buf), None); } -pub fn minimal_op<D>( - d: D, -) -> impl Fn(&mut CoreIsolateState, &mut [ZeroCopyBuf]) -> Op +pub fn minimal_op<D>(d: D) -> impl OpDispatcher where D: Fn(&mut CoreIsolateState, bool, i32, &mut [ZeroCopyBuf]) -> MinimalOp, { diff --git a/cli/ops/plugin.rs b/cli/ops/plugin.rs index 16debac50..ba105cff8 100644 --- a/cli/ops/plugin.rs +++ b/cli/ops/plugin.rs @@ -110,7 +110,8 @@ impl<'a> plugin_api::Interface for PluginInterface<'a> { let plugin_lib = self.plugin_lib.clone(); self.isolate_state.op_registry.register( name, - move |isolate_state, zero_copy| { + move |isolate_state: &mut CoreIsolateState, + zero_copy: &mut [ZeroCopyBuf]| { let mut interface = PluginInterface::new(isolate_state, &plugin_lib); let op = dispatch_op_fn(&mut interface, zero_copy); match op { diff --git a/cli/state.rs b/cli/state.rs index 5f3873510..2d871d74d 100644 --- a/cli/state.rs +++ b/cli/state.rs @@ -16,6 +16,7 @@ use deno_core::ModuleLoadId; use deno_core::ModuleLoader; use deno_core::ModuleSpecifier; use deno_core::Op; +use deno_core::OpDispatcher; use deno_core::ZeroCopyBuf; use futures::future::FutureExt; use futures::Future; @@ -62,10 +63,7 @@ pub struct StateInner { } impl State { - pub fn stateful_json_op<D>( - &self, - dispatcher: D, - ) -> impl Fn(&mut deno_core::CoreIsolateState, &mut [ZeroCopyBuf]) -> Op + pub fn stateful_json_op<D>(&self, dispatcher: D) -> impl OpDispatcher where D: Fn(&State, Value, &mut [ZeroCopyBuf]) -> Result<JsonOp, OpError>, { @@ -73,10 +71,7 @@ impl State { self.core_op(json_op(self.stateful_op(dispatcher))) } - pub fn stateful_json_op2<D>( - &self, - dispatcher: D, - ) -> impl Fn(&mut deno_core::CoreIsolateState, &mut [ZeroCopyBuf]) -> Op + pub fn stateful_json_op2<D>(&self, dispatcher: D) -> impl OpDispatcher where D: Fn( &mut deno_core::CoreIsolateState, @@ -92,13 +87,7 @@ impl State { /// Wrap core `OpDispatcher` to collect metrics. // TODO(ry) this should be private. Is called by stateful_json_op or // stateful_minimal_op - pub fn core_op<D>( - &self, - dispatcher: D, - ) -> impl Fn(&mut deno_core::CoreIsolateState, &mut [ZeroCopyBuf]) -> Op - where - D: Fn(&mut deno_core::CoreIsolateState, &mut [ZeroCopyBuf]) -> Op, - { + pub fn core_op(&self, dispatcher: impl OpDispatcher) -> impl OpDispatcher { let state = self.clone(); move |isolate_state: &mut deno_core::CoreIsolateState, @@ -109,7 +98,7 @@ impl State { let bytes_sent_zero_copy = zero_copy[1..].iter().map(|b| b.len()).sum::<usize>() as u64; - let op = dispatcher(isolate_state, zero_copy); + let op = dispatcher.dispatch(isolate_state, zero_copy); match op { Op::Sync(buf) => { @@ -152,10 +141,7 @@ impl State { } } - pub fn stateful_minimal_op2<D>( - &self, - dispatcher: D, - ) -> impl Fn(&mut deno_core::CoreIsolateState, &mut [ZeroCopyBuf]) -> Op + pub fn stateful_minimal_op2<D>(&self, dispatcher: D) -> impl OpDispatcher where D: Fn( &mut deno_core::CoreIsolateState, |