diff options
Diffstat (limited to 'cli/ops/mod.rs')
-rw-r--r-- | cli/ops/mod.rs | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/cli/ops/mod.rs b/cli/ops/mod.rs index 021c0fa47..bf621e0e1 100644 --- a/cli/ops/mod.rs +++ b/cli/ops/mod.rs @@ -1,7 +1,5 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. use crate::deno_error::GetErrorKind; -use crate::dispatch_minimal::dispatch_minimal; -use crate::dispatch_minimal::parse_min_record; use crate::msg; use crate::state::ThreadSafeState; use crate::tokio_util; @@ -13,12 +11,15 @@ use hyper; use hyper::rt::Future; use tokio_threadpool; +mod dispatch_minimal; +mod io; + mod compiler; use compiler::{op_cache, op_fetch_source_file}; mod errors; use errors::{op_apply_source_map, op_format_error}; mod files; -use files::{op_close, op_open, op_read, op_seek, op_write}; +use files::{op_close, op_open, op_seek}; mod fetch; use fetch::op_fetch; mod fs; @@ -71,6 +72,8 @@ fn empty_buf() -> Buf { } const FLATBUFFER_OP_ID: OpId = 44; +const OP_READ: OpId = 1; +const OP_WRITE: OpId = 2; pub fn dispatch_all( state: &ThreadSafeState, @@ -81,11 +84,18 @@ pub fn dispatch_all( ) -> CoreOp { let bytes_sent_control = control.len(); let bytes_sent_zero_copy = zero_copy.as_ref().map(|b| b.len()).unwrap_or(0); - let op = if op_id != FLATBUFFER_OP_ID { - let min_record = parse_min_record(control).unwrap(); - dispatch_minimal(state, op_id, min_record, zero_copy) - } else { - dispatch_all_legacy(state, control, zero_copy, op_selector) + + let op = match op_id { + OP_READ => { + dispatch_minimal::dispatch(io::op_read, state, control, zero_copy) + } + OP_WRITE => { + dispatch_minimal::dispatch(io::op_write, state, control, zero_copy) + } + FLATBUFFER_OP_ID => { + dispatch_all_legacy(state, control, zero_copy, op_selector) + } + _ => panic!("bad op_id"), }; state.metrics_op_dispatched(bytes_sent_control, bytes_sent_zero_copy); op @@ -226,7 +236,6 @@ pub fn op_selector_std(inner_type: msg::Any) -> Option<CliDispatchFn> { msg::Any::Open => Some(op_open), msg::Any::PermissionRevoke => Some(op_revoke_permission), msg::Any::Permissions => Some(op_permissions), - msg::Any::Read => Some(op_read), msg::Any::ReadDir => Some(op_read_dir), msg::Any::Readlink => Some(op_read_link), msg::Any::Remove => Some(op_remove), @@ -245,7 +254,6 @@ pub fn op_selector_std(inner_type: msg::Any) -> Option<CliDispatchFn> { msg::Any::Truncate => Some(op_truncate), msg::Any::HomeDir => Some(op_home_dir), msg::Any::Utime => Some(op_utime), - msg::Any::Write => Some(op_write), // TODO(ry) split these out so that only the appropriate Workers can access // them. |