summaryrefslogtreecommitdiff
path: root/ext/net/ops_unix.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2023-09-12 15:39:21 +0200
committerGitHub <noreply@github.com>2023-09-12 15:39:21 +0200
commit08d2a32060a66e47dcccd99428d2ad13d7af29a9 (patch)
treec4ec82634e24eb2309e32a1063b89ee688a481ec /ext/net/ops_unix.rs
parentbdf1850679ef7d94fbc603f1170af2e232671249 (diff)
refactor: rewrite ext/net/ ops to op2 (#20471)
Diffstat (limited to 'ext/net/ops_unix.rs')
-rw-r--r--ext/net/ops_unix.rs33
1 files changed, 20 insertions, 13 deletions
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<RefCell<OpState>>,
- rid: ResourceId,
+ #[smi] rid: ResourceId,
) -> Result<(ResourceId, Option<String>, Option<String>), 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<NP>(
state: Rc<RefCell<OpState>>,
- path: String,
+ #[string] path: String,
) -> Result<(ResourceId, Option<String>, Option<String>), 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<RefCell<OpState>>,
- rid: ResourceId,
- mut buf: JsBuffer,
+ #[smi] rid: ResourceId,
+ #[buffer] mut buf: JsBuffer,
) -> Result<(usize, Option<String>), AnyError> {
let resource = state
.borrow()
@@ -185,10 +189,11 @@ where
Ok(nwritten)
}
-#[op]
+#[op2]
+#[serde]
pub fn op_net_listen_unix<NP>(
state: &mut OpState,
- path: String,
+ #[string] path: String,
) -> Result<(ResourceId, Option<String>), AnyError>
where
NP: NetPermissions + 'static,
@@ -231,10 +236,11 @@ where
Ok((rid, pathname))
}
-#[op]
+#[op2]
+#[serde]
pub fn op_net_listen_unixpacket<NP>(
state: &mut OpState,
- path: String,
+ #[string] path: String,
) -> Result<(ResourceId, Option<String>), AnyError>
where
NP: NetPermissions + 'static,
@@ -243,10 +249,11 @@ where
net_listen_unixpacket::<NP>(state, path)
}
-#[op]
+#[op2]
+#[serde]
pub fn op_node_unstable_net_listen_unixpacket<NP>(
state: &mut OpState,
- path: String,
+ #[string] path: String,
) -> Result<(ResourceId, Option<String>), AnyError>
where
NP: NetPermissions + 'static,