From d77f3fba03abef07bf7aa7b83f86d6e99077f4b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Wed, 20 Sep 2023 04:39:27 +0200 Subject: refactor: rewrite BC, cache exts to op2 (#20486) Co-authored-by: Matt Mastracci --- ext/broadcast_channel/lib.rs | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'ext/broadcast_channel/lib.rs') diff --git a/ext/broadcast_channel/lib.rs b/ext/broadcast_channel/lib.rs index 56ce4b3bd..6ee10f9c0 100644 --- a/ext/broadcast_channel/lib.rs +++ b/ext/broadcast_channel/lib.rs @@ -11,7 +11,7 @@ use std::rc::Rc; use async_trait::async_trait; use deno_core::error::AnyError; -use deno_core::op; +use deno_core::op2; use deno_core::JsBuffer; use deno_core::OpState; use deno_core::Resource; @@ -42,7 +42,8 @@ pub type Message = (String, Vec); struct Unstable(bool); // --unstable -#[op] +#[op2(fast)] +#[smi] pub fn op_broadcast_subscribe( state: &mut OpState, ) -> Result @@ -63,10 +64,10 @@ where Ok(state.resource_table.add(resource)) } -#[op] +#[op2(fast)] pub fn op_broadcast_unsubscribe( state: &mut OpState, - rid: ResourceId, + #[smi] rid: ResourceId, ) -> Result<(), AnyError> where BC: BroadcastChannel + 'static, @@ -76,12 +77,12 @@ where bc.unsubscribe(&resource) } -#[op] +#[op2(async)] pub async fn op_broadcast_send( state: Rc>, - rid: ResourceId, - name: String, - buf: JsBuffer, + #[smi] rid: ResourceId, + #[string] name: String, + #[buffer] buf: JsBuffer, ) -> Result<(), AnyError> where BC: BroadcastChannel + 'static, @@ -91,10 +92,11 @@ where bc.send(&resource, name, buf.to_vec()).await } -#[op] +#[op2(async)] +#[serde] pub async fn op_broadcast_recv( state: Rc>, - rid: ResourceId, + #[smi] rid: ResourceId, ) -> Result, AnyError> where BC: BroadcastChannel + 'static, -- cgit v1.2.3