summaryrefslogtreecommitdiff
path: root/ext/web/message_port.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2023-09-14 23:05:18 +0200
committerGitHub <noreply@github.com>2023-09-14 23:05:18 +0200
commit5e7435fb8010a6d90f1b88d68ee8c431abf846e1 (patch)
tree6d4dda4dc6d23f10dfd9f3ec4683a66f88828c27 /ext/web/message_port.rs
parentdc505e905ec256f034a963f12752dcc4187cb7b9 (diff)
refactor: rewrite more ops to op2 macro (#20478)
Diffstat (limited to 'ext/web/message_port.rs')
-rw-r--r--ext/web/message_port.rs16
1 files changed, 9 insertions, 7 deletions
diff --git a/ext/web/message_port.rs b/ext/web/message_port.rs
index 73214ab8e..df8a8056b 100644
--- a/ext/web/message_port.rs
+++ b/ext/web/message_port.rs
@@ -6,7 +6,7 @@ use std::rc::Rc;
use deno_core::error::type_error;
use deno_core::error::AnyError;
-use deno_core::op;
+use deno_core::op2;
use deno_core::CancelFuture;
use deno_core::CancelHandle;
@@ -111,7 +111,8 @@ impl Resource for MessagePortResource {
}
}
-#[op]
+#[op2]
+#[serde]
pub fn op_message_port_create_entangled(
state: &mut OpState,
) -> (ResourceId, ResourceId) {
@@ -191,11 +192,11 @@ pub struct JsMessageData {
transferables: Vec<JsTransferable>,
}
-#[op]
+#[op2]
pub fn op_message_port_post_message(
state: &mut OpState,
- rid: ResourceId,
- data: JsMessageData,
+ #[smi] rid: ResourceId,
+ #[serde] data: JsMessageData,
) -> Result<(), AnyError> {
for js_transferable in &data.transferables {
if let JsTransferable::MessagePort(id) = js_transferable {
@@ -210,10 +211,11 @@ pub fn op_message_port_post_message(
resource.port.send(state, data)
}
-#[op]
+#[op2(async)]
+#[serde]
pub async fn op_message_port_recv_message(
state: Rc<RefCell<OpState>>,
- rid: ResourceId,
+ #[smi] rid: ResourceId,
) -> Result<Option<JsMessageData>, AnyError> {
let resource = {
let state = state.borrow();