From 2aed322dd507a8568b6ee6f4897e9a8e3220f763 Mon Sep 17 00:00:00 2001 From: Aaron O'Mullan Date: Mon, 5 Apr 2021 18:40:24 +0200 Subject: refactor: convert ops to use serde_v8 (#10009) This commit rewrites most of the ops to use "serde_v8" instead of "json" serialization. --- op_crates/webgpu/texture.rs | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'op_crates/webgpu/texture.rs') diff --git a/op_crates/webgpu/texture.rs b/op_crates/webgpu/texture.rs index 24824215c..28b8ca1a4 100644 --- a/op_crates/webgpu/texture.rs +++ b/op_crates/webgpu/texture.rs @@ -2,15 +2,13 @@ use deno_core::error::AnyError; use deno_core::error::{bad_resource_id, not_supported}; -use deno_core::serde_json::json; -use deno_core::serde_json::Value; use deno_core::ResourceId; use deno_core::ZeroCopyBuf; use deno_core::{OpState, Resource}; use serde::Deserialize; use std::borrow::Cow; -use super::error::WebGpuError; +use super::error::WebGpuResult; pub(crate) struct WebGpuTexture(pub(crate) wgpu_core::id::TextureId); impl Resource for WebGpuTexture { fn name(&self) -> Cow { @@ -148,7 +146,7 @@ pub fn op_webgpu_create_texture( state: &mut OpState, args: CreateTextureArgs, _zero_copy: Option, -) -> Result { +) -> Result { let instance = state.borrow::(); let device_resource = state .resource_table @@ -186,10 +184,7 @@ pub fn op_webgpu_create_texture( let rid = state.resource_table.add(WebGpuTexture(texture)); - Ok(json!({ - "rid": rid, - "err": maybe_err.map(WebGpuError::from) - })) + Ok(WebGpuResult::rid_err(rid, maybe_err)) } #[derive(Deserialize)] @@ -210,7 +205,7 @@ pub fn op_webgpu_create_texture_view( state: &mut OpState, args: CreateTextureViewArgs, _zero_copy: Option, -) -> Result { +) -> Result { let instance = state.borrow::(); let texture_resource = state .resource_table @@ -250,8 +245,5 @@ pub fn op_webgpu_create_texture_view( let rid = state.resource_table.add(WebGpuTextureView(texture_view)); - Ok(json!({ - "rid": rid, - "err": maybe_err.map(WebGpuError::from) - })) + Ok(WebGpuResult::rid_err(rid, maybe_err)) } -- cgit v1.2.3