diff options
author | crowlKats <13135287+crowlKats@users.noreply.github.com> | 2021-02-18 13:54:57 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-18 13:54:57 +0100 |
commit | 666c4b77b07abea8ae4f778d5a7e7fabdc7159a8 (patch) | |
tree | 0b3da2af1f8ad72996d58d65f82ce20228599654 /runtime/ops/web_worker.rs | |
parent | 2225e83da2d118678e3df1e2801af195166bc65a (diff) |
feat(runtime/ops): strongly typed deserialization of JSON ops (#9532)
Diffstat (limited to 'runtime/ops/web_worker.rs')
-rw-r--r-- | runtime/ops/web_worker.rs | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/runtime/ops/web_worker.rs b/runtime/ops/web_worker.rs index aeaece89e..17561882e 100644 --- a/runtime/ops/web_worker.rs +++ b/runtime/ops/web_worker.rs @@ -3,7 +3,7 @@ use crate::web_worker::WebWorkerHandle; use crate::web_worker::WorkerEvent; use deno_core::futures::channel::mpsc; -use deno_core::serde_json::json; +use deno_core::serde_json::{json, Value}; pub fn init( rt: &mut deno_core::JsRuntime, @@ -15,7 +15,7 @@ pub fn init( super::reg_json_sync( rt, "op_worker_post_message", - move |_state, _args, bufs| { + move |_state, _args: Value, bufs| { assert_eq!(bufs.len(), 1, "Invalid number of arguments"); let msg_buf: Box<[u8]> = (*bufs[0]).into(); sender_ @@ -27,11 +27,15 @@ pub fn init( ); // Notify host that guest worker closes. - super::reg_json_sync(rt, "op_worker_close", move |_state, _args, _bufs| { - // Notify parent that we're finished - sender.clone().close_channel(); - // Terminate execution of current worker - handle.terminate(); - Ok(json!({})) - }); + super::reg_json_sync( + rt, + "op_worker_close", + move |_state, _args: Value, _bufs| { + // Notify parent that we're finished + sender.clone().close_channel(); + // Terminate execution of current worker + handle.terminate(); + Ok(json!({})) + }, + ); } |