mirror of
https://github.com/denoland/deno.git
synced 2025-08-03 18:38:33 +00:00
move runtime ops to serde ops (#9828)
This commit is contained in:
parent
62716422b9
commit
b59151f39e
13 changed files with 176 additions and 264 deletions
|
@ -8,7 +8,6 @@ use crate::permissions::Permissions;
|
|||
use deno_core::error::bad_resource_id;
|
||||
use deno_core::error::type_error;
|
||||
use deno_core::error::AnyError;
|
||||
use deno_core::serde_json;
|
||||
use deno_core::serde_json::json;
|
||||
use deno_core::serde_json::Value;
|
||||
use deno_core::AsyncMutFuture;
|
||||
|
@ -54,7 +53,7 @@ fn subprocess_stdio_map(s: &str) -> Result<std::process::Stdio, AnyError> {
|
|||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct RunArgs {
|
||||
pub struct RunArgs {
|
||||
cmd: Vec<String>,
|
||||
cwd: Option<String>,
|
||||
env: Vec<(String, String)>,
|
||||
|
@ -84,10 +83,9 @@ impl ChildResource {
|
|||
|
||||
fn op_run(
|
||||
state: &mut OpState,
|
||||
args: Value,
|
||||
run_args: RunArgs,
|
||||
_zero_copy: &mut [ZeroCopyBuf],
|
||||
) -> Result<Value, AnyError> {
|
||||
let run_args: RunArgs = serde_json::from_value(args)?;
|
||||
state.borrow::<Permissions>().run.check()?;
|
||||
|
||||
let args = run_args.cmd;
|
||||
|
@ -179,16 +177,15 @@ fn op_run(
|
|||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct RunStatusArgs {
|
||||
pub struct RunStatusArgs {
|
||||
rid: i32,
|
||||
}
|
||||
|
||||
async fn op_run_status(
|
||||
state: Rc<RefCell<OpState>>,
|
||||
args: Value,
|
||||
args: RunStatusArgs,
|
||||
_zero_copy: BufVec,
|
||||
) -> Result<Value, AnyError> {
|
||||
let args: RunStatusArgs = serde_json::from_value(args)?;
|
||||
let rid = args.rid as u32;
|
||||
|
||||
{
|
||||
|
@ -281,13 +278,12 @@ struct KillArgs {
|
|||
|
||||
fn op_kill(
|
||||
state: &mut OpState,
|
||||
args: Value,
|
||||
args: KillArgs,
|
||||
_zero_copy: &mut [ZeroCopyBuf],
|
||||
) -> Result<Value, AnyError> {
|
||||
super::check_unstable(state, "Deno.kill");
|
||||
state.borrow::<Permissions>().run.check()?;
|
||||
|
||||
let args: KillArgs = serde_json::from_value(args)?;
|
||||
kill(args.pid, args.signo)?;
|
||||
Ok(json!({}))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue