summaryrefslogtreecommitdiff
path: root/runtime/ops/net.rs
diff options
context:
space:
mode:
authorAaron O'Mullan <aaron.omullan@gmail.com>2021-04-05 18:40:24 +0200
committerGitHub <noreply@github.com>2021-04-05 18:40:24 +0200
commit2aed322dd507a8568b6ee6f4897e9a8e3220f763 (patch)
treee9a45c0b7688a9881ea9ce132b92554ef2955ad6 /runtime/ops/net.rs
parent284e6c303956e8ca20af63b4ecc045438a260fe6 (diff)
refactor: convert ops to use serde_v8 (#10009)
This commit rewrites most of the ops to use "serde_v8" instead of "json" serialization.
Diffstat (limited to 'runtime/ops/net.rs')
-rw-r--r--runtime/ops/net.rs19
1 files changed, 8 insertions, 11 deletions
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<RefCell<OpState>>,
- args: Value,
+ args: AcceptArgs,
_buf: Option<ZeroCopyBuf>,
) -> Result<Value, AnyError> {
- 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<RefCell<OpState>>,
- args: Value,
+ args: ReceiveArgs,
zero_copy: Option<ZeroCopyBuf>,
) -> Result<Value, AnyError> {
- 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<RefCell<OpState>>,
- args: Value,
+ args: SendArgs,
zero_copy: Option<ZeroCopyBuf>,
) -> Result<Value, AnyError> {
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<RefCell<OpState>>,
- args: Value,
+ args: ConnectArgs,
_zero_copy: Option<ZeroCopyBuf>,
) -> Result<Value, AnyError> {
- 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<ZeroCopyBuf>,
) -> Result<Value, AnyError> {
let permissions = state.borrow::<Permissions>();
- match serde_json::from_value(args)? {
+ match args {
ListenArgs {
transport,
transport_args: ArgsEnum::Ip(args),