summaryrefslogtreecommitdiff
path: root/cli/cli_behavior.rs
blob: 510b2608c88b150e48447a430e5122dd35496e1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
use crate::isolate_state::*;
use crate::ops;
use deno::deno_buf;
use deno::Behavior;
use deno::Op;
use std::sync::Arc;

/// Implements deno::Behavior for the main Deno command-line.
pub struct CliBehavior {
  pub state: Arc<IsolateState>,
}

impl CliBehavior {
  pub fn new(state: Arc<IsolateState>) -> Self {
    Self { state }
  }
}

impl Behavior for CliBehavior {
  fn dispatch(
    &mut self,
    control: &[u8],
    zero_copy: deno_buf,
  ) -> (bool, Box<Op>) {
    ops::dispatch_all(&self.state, control, zero_copy, ops::op_selector_std)
  }
}