From 2aed322dd507a8568b6ee6f4897e9a8e3220f763 Mon Sep 17 00:00:00 2001 From: Aaron O'Mullan Date: Mon, 5 Apr 2021 18:40:24 +0200 Subject: refactor: convert ops to use serde_v8 (#10009) This commit rewrites most of the ops to use "serde_v8" instead of "json" serialization. --- runtime/ops/net.rs | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'runtime/ops/net.rs') diff --git a/runtime/ops/net.rs b/runtime/ops/net.rs index 7d81fcee0..224fb5570 100644 --- a/runtime/ops/net.rs +++ b/runtime/ops/net.rs @@ -9,7 +9,6 @@ use deno_core::error::generic_error; use deno_core::error::null_opbuf; 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::AsyncRefCell; @@ -109,10 +108,9 @@ async fn accept_tcp( async fn op_accept( state: Rc>, - args: Value, + args: AcceptArgs, _buf: Option, ) -> Result { - let args: AcceptArgs = serde_json::from_value(args)?; match args.transport.as_str() { "tcp" => accept_tcp(state, args, _buf).await, #[cfg(unix)] @@ -163,10 +161,9 @@ async fn receive_udp( async fn op_datagram_receive( state: Rc>, - args: Value, + args: ReceiveArgs, zero_copy: Option, ) -> Result { - let args: ReceiveArgs = serde_json::from_value(args)?; match args.transport.as_str() { "udp" => receive_udp(state, args, zero_copy).await, #[cfg(unix)] @@ -188,13 +185,13 @@ struct SendArgs { async fn op_datagram_send( state: Rc>, - args: Value, + args: SendArgs, zero_copy: Option, ) -> Result { let zero_copy = zero_copy.ok_or_else(null_opbuf)?; let zero_copy = zero_copy.clone(); - match serde_json::from_value(args)? { + match args { SendArgs { rid, transport, @@ -257,10 +254,10 @@ struct ConnectArgs { async fn op_connect( state: Rc>, - args: Value, + args: ConnectArgs, _zero_copy: Option, ) -> Result { - match serde_json::from_value(args)? { + match args { ConnectArgs { transport, transport_args: ArgsEnum::Ip(args), @@ -421,11 +418,11 @@ fn listen_udp( fn op_listen( state: &mut OpState, - args: Value, + args: ListenArgs, _zero_copy: Option, ) -> Result { let permissions = state.borrow::(); - match serde_json::from_value(args)? { + match args { ListenArgs { transport, transport_args: ArgsEnum::Ip(args), -- cgit v1.2.3