From 08d2a32060a66e47dcccd99428d2ad13d7af29a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Tue, 12 Sep 2023 15:39:21 +0200 Subject: refactor: rewrite ext/net/ ops to op2 (#20471) --- ext/net/ops_unix.rs | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) (limited to 'ext/net/ops_unix.rs') diff --git a/ext/net/ops_unix.rs b/ext/net/ops_unix.rs index f3ff9617a..1d20f2911 100644 --- a/ext/net/ops_unix.rs +++ b/ext/net/ops_unix.rs @@ -6,6 +6,7 @@ use deno_core::error::bad_resource; use deno_core::error::custom_error; use deno_core::error::AnyError; use deno_core::op; +use deno_core::op2; use deno_core::AsyncRefCell; use deno_core::CancelHandle; use deno_core::CancelTryFuture; @@ -72,10 +73,11 @@ pub struct UnixListenArgs { pub path: String, } -#[op] +#[op2(async)] +#[serde] pub async fn op_net_accept_unix( state: Rc>, - rid: ResourceId, + #[smi] rid: ResourceId, ) -> Result<(ResourceId, Option, Option), AnyError> { let resource = state .borrow() @@ -103,10 +105,11 @@ pub async fn op_net_accept_unix( Ok((rid, local_addr_path, remote_addr_path)) } -#[op] +#[op2(async)] +#[serde] pub async fn op_net_connect_unix( state: Rc>, - path: String, + #[string] path: String, ) -> Result<(ResourceId, Option, Option), AnyError> where NP: NetPermissions + 'static, @@ -134,11 +137,12 @@ where Ok((rid, local_addr_path, remote_addr_path)) } -#[op] +#[op2(async)] +#[serde] pub async fn op_net_recv_unixpacket( state: Rc>, - rid: ResourceId, - mut buf: JsBuffer, + #[smi] rid: ResourceId, + #[buffer] mut buf: JsBuffer, ) -> Result<(usize, Option), AnyError> { let resource = state .borrow() @@ -185,10 +189,11 @@ where Ok(nwritten) } -#[op] +#[op2] +#[serde] pub fn op_net_listen_unix( state: &mut OpState, - path: String, + #[string] path: String, ) -> Result<(ResourceId, Option), AnyError> where NP: NetPermissions + 'static, @@ -231,10 +236,11 @@ where Ok((rid, pathname)) } -#[op] +#[op2] +#[serde] pub fn op_net_listen_unixpacket( state: &mut OpState, - path: String, + #[string] path: String, ) -> Result<(ResourceId, Option), AnyError> where NP: NetPermissions + 'static, @@ -243,10 +249,11 @@ where net_listen_unixpacket::(state, path) } -#[op] +#[op2] +#[serde] pub fn op_node_unstable_net_listen_unixpacket( state: &mut OpState, - path: String, + #[string] path: String, ) -> Result<(ResourceId, Option), AnyError> where NP: NetPermissions + 'static, -- cgit v1.2.3