From 77a00ce1fb4ae2523e22b9b84ae09a0200502e38 Mon Sep 17 00:00:00 2001 From: Leo K Date: Tue, 5 Oct 2021 22:38:27 +0200 Subject: chore: various op cleanup (#12329) --- ext/crypto/lib.rs | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) (limited to 'ext/crypto/lib.rs') diff --git a/ext/crypto/lib.rs b/ext/crypto/lib.rs index 157a9f04b..a562eaf01 100644 --- a/ext/crypto/lib.rs +++ b/ext/crypto/lib.rs @@ -2,7 +2,6 @@ use deno_core::error::custom_error; use deno_core::error::not_supported; -use deno_core::error::null_opbuf; use deno_core::error::type_error; use deno_core::error::AnyError; use deno_core::include_js_files; @@ -296,9 +295,8 @@ pub struct SignArg { pub async fn op_crypto_sign_key( _state: Rc>, args: SignArg, - zero_copy: Option, + zero_copy: ZeroCopyBuf, ) -> Result { - let zero_copy = zero_copy.ok_or_else(null_opbuf)?; let data = &*zero_copy; let algorithm = args.algorithm; @@ -451,9 +449,8 @@ pub struct VerifyArg { pub async fn op_crypto_verify_key( _state: Rc>, args: VerifyArg, - zero_copy: Option, + zero_copy: ZeroCopyBuf, ) -> Result { - let zero_copy = zero_copy.ok_or_else(null_opbuf)?; let data = &*zero_copy; let algorithm = args.algorithm; @@ -599,7 +596,7 @@ pub struct ExportKeyArg { pub async fn op_crypto_export_key( _state: Rc>, args: ExportKeyArg, - _zero_copy: Option, + _: (), ) -> Result { let algorithm = args.algorithm; match algorithm { @@ -731,9 +728,8 @@ pub struct DeriveKeyArg { pub async fn op_crypto_derive_bits( _state: Rc>, args: DeriveKeyArg, - zero_copy: Option, + zero_copy: ZeroCopyBuf, ) -> Result { - let zero_copy = zero_copy.ok_or_else(null_opbuf)?; let salt = &*zero_copy; let algorithm = args.algorithm; match algorithm { @@ -798,9 +794,8 @@ pub struct EncryptArg { pub async fn op_crypto_encrypt_key( _state: Rc>, args: EncryptArg, - zero_copy: Option, + zero_copy: ZeroCopyBuf, ) -> Result { - let zero_copy = zero_copy.ok_or_else(null_opbuf)?; let data = &*zero_copy; let algorithm = args.algorithm; @@ -1035,9 +1030,8 @@ pub struct ImportKeyResult { pub async fn op_crypto_import_key( _state: Rc>, args: ImportKeyArg, - zero_copy: Option, + zero_copy: ZeroCopyBuf, ) -> Result { - let zero_copy = zero_copy.ok_or_else(null_opbuf)?; let data = &*zero_copy; let algorithm = args.algorithm; @@ -1359,9 +1353,8 @@ pub struct DecryptArg { pub async fn op_crypto_decrypt_key( _state: Rc>, args: DecryptArg, - zero_copy: Option, + zero_copy: ZeroCopyBuf, ) -> Result { - let zero_copy = zero_copy.ok_or_else(null_opbuf)?; let data = &*zero_copy; let algorithm = args.algorithm; @@ -1431,11 +1424,10 @@ pub fn op_crypto_random_uuid( pub async fn op_crypto_subtle_digest( _state: Rc>, algorithm: CryptoHash, - data: Option, + data: ZeroCopyBuf, ) -> Result { - let input = data.ok_or_else(null_opbuf)?; let output = tokio::task::spawn_blocking(move || { - digest::digest(algorithm.into(), &input) + digest::digest(algorithm.into(), &data) .as_ref() .to_vec() .into() -- cgit v1.2.3