diff options
author | Aaron O'Mullan <aaron.omullan@gmail.com> | 2021-04-05 18:40:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-05 18:40:24 +0200 |
commit | 2aed322dd507a8568b6ee6f4897e9a8e3220f763 (patch) | |
tree | e9a45c0b7688a9881ea9ce132b92554ef2955ad6 /op_crates/webgpu/texture.rs | |
parent | 284e6c303956e8ca20af63b4ecc045438a260fe6 (diff) |
refactor: convert ops to use serde_v8 (#10009)
This commit rewrites most of the ops to use "serde_v8" instead
of "json" serialization.
Diffstat (limited to 'op_crates/webgpu/texture.rs')
-rw-r--r-- | op_crates/webgpu/texture.rs | 18 |
1 files changed, 5 insertions, 13 deletions
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<str> { @@ -148,7 +146,7 @@ pub fn op_webgpu_create_texture( state: &mut OpState, args: CreateTextureArgs, _zero_copy: Option<ZeroCopyBuf>, -) -> Result<Value, AnyError> { +) -> Result<WebGpuResult, AnyError> { let instance = state.borrow::<super::Instance>(); 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<ZeroCopyBuf>, -) -> Result<Value, AnyError> { +) -> Result<WebGpuResult, AnyError> { let instance = state.borrow::<super::Instance>(); 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)) } |