summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorAaron O'Mullan <aaron.omullan@gmail.com>2022-03-16 00:33:46 +0100
committerGitHub <noreply@github.com>2022-03-16 00:33:46 +0100
commitbd481bf095f920a419ea55543f911e087f98f36f (patch)
treeb4f97aabfd3734770c5367b1253511a02d86af87 /ext
parent672f66dde1f7ec87282d37e10cac2cdd36e5f181 (diff)
feat(ops): optional OpState (#13954)
Diffstat (limited to 'ext')
-rw-r--r--ext/crypto/decrypt.rs5
-rw-r--r--ext/crypto/encrypt.rs5
-rw-r--r--ext/crypto/export_key.rs2
-rw-r--r--ext/crypto/generate_key.rs5
-rw-r--r--ext/crypto/import_key.rs2
-rw-r--r--ext/crypto/lib.rs8
-rw-r--r--ext/ffi/lib.rs6
-rw-r--r--ext/http/lib.rs5
-rw-r--r--ext/url/lib.rs4
-rw-r--r--ext/url/urlpattern.rs2
-rw-r--r--ext/web/lib.rs23
11 files changed, 7 insertions, 60 deletions
diff --git a/ext/crypto/decrypt.rs b/ext/crypto/decrypt.rs
index a8666de89..b3989a7f6 100644
--- a/ext/crypto/decrypt.rs
+++ b/ext/crypto/decrypt.rs
@@ -1,6 +1,3 @@
-use std::cell::RefCell;
-use std::rc::Rc;
-
use crate::shared::*;
use aes::BlockEncrypt;
use aes::NewBlockCipher;
@@ -25,7 +22,6 @@ use deno_core::error::custom_error;
use deno_core::error::type_error;
use deno_core::error::AnyError;
use deno_core::op;
-use deno_core::OpState;
use deno_core::ZeroCopyBuf;
use rsa::pkcs1::FromRsaPrivateKey;
use rsa::PaddingScheme;
@@ -79,7 +75,6 @@ pub enum DecryptAlgorithm {
#[op]
pub async fn op_crypto_decrypt(
- _state: Rc<RefCell<OpState>>,
opts: DecryptOptions,
data: ZeroCopyBuf,
) -> Result<ZeroCopyBuf, AnyError> {
diff --git a/ext/crypto/encrypt.rs b/ext/crypto/encrypt.rs
index b93ca0952..9d0dd3565 100644
--- a/ext/crypto/encrypt.rs
+++ b/ext/crypto/encrypt.rs
@@ -1,6 +1,3 @@
-use std::cell::RefCell;
-use std::rc::Rc;
-
use crate::shared::*;
use aes::cipher::NewCipher;
@@ -27,7 +24,6 @@ use ctr::flavors::Ctr64BE;
use ctr::flavors::CtrFlavor;
use deno_core::error::type_error;
use deno_core::error::AnyError;
-use deno_core::OpState;
use deno_core::ZeroCopyBuf;
use rand::rngs::OsRng;
use rsa::pkcs1::FromRsaPublicKey;
@@ -83,7 +79,6 @@ pub enum EncryptAlgorithm {
#[op]
pub async fn op_crypto_encrypt(
- _state: Rc<RefCell<OpState>>,
opts: EncryptOptions,
data: ZeroCopyBuf,
) -> Result<ZeroCopyBuf, AnyError> {
diff --git a/ext/crypto/export_key.rs b/ext/crypto/export_key.rs
index 8131f859d..64d2d1079 100644
--- a/ext/crypto/export_key.rs
+++ b/ext/crypto/export_key.rs
@@ -1,7 +1,6 @@
use deno_core::error::custom_error;
use deno_core::error::AnyError;
use deno_core::op;
-use deno_core::OpState;
use deno_core::ZeroCopyBuf;
use rsa::pkcs1::UIntBytes;
use serde::Deserialize;
@@ -87,7 +86,6 @@ pub enum ExportKeyResult {
#[op]
pub fn op_crypto_export_key(
- _state: &mut OpState,
opts: ExportKeyOptions,
key_data: RawKeyData,
) -> Result<ExportKeyResult, AnyError> {
diff --git a/ext/crypto/generate_key.rs b/ext/crypto/generate_key.rs
index 22f0913ec..99f9fac62 100644
--- a/ext/crypto/generate_key.rs
+++ b/ext/crypto/generate_key.rs
@@ -1,10 +1,6 @@
-use std::cell::RefCell;
-use std::rc::Rc;
-
use crate::shared::*;
use deno_core::error::AnyError;
use deno_core::op;
-use deno_core::OpState;
use deno_core::ZeroCopyBuf;
use elliptic_curve::rand_core::OsRng;
use num_traits::FromPrimitive;
@@ -44,7 +40,6 @@ pub enum GenerateKeyOptions {
#[op]
pub async fn op_crypto_generate_key(
- _state: Rc<RefCell<OpState>>,
opts: GenerateKeyOptions,
) -> Result<ZeroCopyBuf, AnyError> {
let fun = || match opts {
diff --git a/ext/crypto/import_key.rs b/ext/crypto/import_key.rs
index 3d29c9947..9b8a9aa5c 100644
--- a/ext/crypto/import_key.rs
+++ b/ext/crypto/import_key.rs
@@ -1,6 +1,5 @@
use deno_core::error::AnyError;
use deno_core::op;
-use deno_core::OpState;
use deno_core::ZeroCopyBuf;
use elliptic_curve::pkcs8::der::Decodable as Pkcs8Decodable;
use elliptic_curve::pkcs8::PrivateKeyInfo;
@@ -90,7 +89,6 @@ pub enum ImportKeyResult {
#[op]
pub fn op_crypto_import_key(
- _state: &mut OpState,
opts: ImportKeyOptions,
key_data: KeyData,
) -> Result<ImportKeyResult, AnyError> {
diff --git a/ext/crypto/lib.rs b/ext/crypto/lib.rs
index e45e3d272..a2dc8e626 100644
--- a/ext/crypto/lib.rs
+++ b/ext/crypto/lib.rs
@@ -17,9 +17,7 @@ use deno_core::ZeroCopyBuf;
use serde::Deserialize;
use shared::operation_error;
-use std::cell::RefCell;
use std::num::NonZeroU32;
-use std::rc::Rc;
use p256::elliptic_curve::sec1::FromEncodedPoint;
use p256::pkcs8::FromPrivateKey;
@@ -169,7 +167,6 @@ pub struct SignArg {
#[op]
pub async fn op_crypto_sign_key(
- _state: Rc<RefCell<OpState>>,
args: SignArg,
zero_copy: ZeroCopyBuf,
) -> Result<ZeroCopyBuf, AnyError> {
@@ -324,7 +321,6 @@ pub struct VerifyArg {
#[op]
pub async fn op_crypto_verify_key(
- _state: Rc<RefCell<OpState>>,
args: VerifyArg,
zero_copy: ZeroCopyBuf,
) -> Result<bool, AnyError> {
@@ -485,7 +481,6 @@ pub struct DeriveKeyArg {
#[op]
pub async fn op_crypto_derive_bits(
- _state: Rc<RefCell<OpState>>,
args: DeriveKeyArg,
zero_copy: Option<ZeroCopyBuf>,
) -> Result<ZeroCopyBuf, AnyError> {
@@ -807,7 +802,6 @@ pub fn op_crypto_random_uuid(state: &mut OpState) -> Result<String, AnyError> {
#[op]
pub async fn op_crypto_subtle_digest(
- _state: Rc<RefCell<OpState>>,
algorithm: CryptoHash,
data: ZeroCopyBuf,
) -> Result<ZeroCopyBuf, AnyError> {
@@ -831,7 +825,6 @@ pub struct WrapUnwrapKeyArg {
#[op]
pub fn op_crypto_wrap_key(
- _state: &mut OpState,
args: WrapUnwrapKeyArg,
data: ZeroCopyBuf,
) -> Result<ZeroCopyBuf, AnyError> {
@@ -861,7 +854,6 @@ pub fn op_crypto_wrap_key(
#[op]
pub fn op_crypto_unwrap_key(
- _state: &mut OpState,
args: WrapUnwrapKeyArg,
data: ZeroCopyBuf,
) -> Result<ZeroCopyBuf, AnyError> {
diff --git a/ext/ffi/lib.rs b/ext/ffi/lib.rs
index 07297071a..6ddeee51c 100644
--- a/ext/ffi/lib.rs
+++ b/ext/ffi/lib.rs
@@ -648,17 +648,13 @@ fn ffi_call(args: FfiCallArgs, symbol: &Symbol) -> Result<Value, AnyError> {
}
#[op]
-fn op_ffi_call_ptr(
- _state: &mut deno_core::OpState,
- args: FfiCallPtrArgs,
-) -> Result<Value, AnyError> {
+fn op_ffi_call_ptr(args: FfiCallPtrArgs) -> Result<Value, AnyError> {
let symbol = args.get_symbol();
ffi_call(args.into(), &symbol)
}
#[op]
async fn op_ffi_call_ptr_nonblocking(
- _state: Rc<RefCell<deno_core::OpState>>,
args: FfiCallPtrArgs,
) -> Result<Value, AnyError> {
let symbol = args.get_symbol();
diff --git a/ext/http/lib.rs b/ext/http/lib.rs
index f57132555..535f52a6c 100644
--- a/ext/http/lib.rs
+++ b/ext/http/lib.rs
@@ -797,10 +797,7 @@ async fn op_http_read(
}
#[op]
-fn op_http_websocket_accept_header(
- _: &mut OpState,
- key: String,
-) -> Result<String, AnyError> {
+fn op_http_websocket_accept_header(key: String) -> Result<String, AnyError> {
let digest = ring::digest::digest(
&ring::digest::SHA1_FOR_LEGACY_USE_ONLY,
format!("{}258EAFA5-E914-47DA-95CA-C5AB0DC85B11", key).as_bytes(),
diff --git a/ext/url/lib.rs b/ext/url/lib.rs
index 4187b7664..0fa389fb0 100644
--- a/ext/url/lib.rs
+++ b/ext/url/lib.rs
@@ -58,7 +58,6 @@ type UrlParts = String;
/// optional part to "set" after parsing. Return `UrlParts`.
#[op]
pub fn op_url_parse(
- _state: &mut deno_core::OpState,
href: String,
base_href: Option<String>,
) -> Result<UrlParts, AnyError> {
@@ -92,7 +91,6 @@ pub enum UrlSetter {
#[op]
pub fn op_url_reparse(
- _state: &mut deno_core::OpState,
href: String,
setter_opts: (UrlSetter, String),
) -> Result<UrlParts, AnyError> {
@@ -162,7 +160,6 @@ fn url_result(
#[op]
pub fn op_url_parse_search_params(
- _state: &mut deno_core::OpState,
args: Option<String>,
zero_copy: Option<ZeroCopyBuf>,
) -> Result<Vec<(String, String)>, AnyError> {
@@ -182,7 +179,6 @@ pub fn op_url_parse_search_params(
#[op]
pub fn op_url_stringify_search_params(
- _state: &mut deno_core::OpState,
args: Vec<(String, String)>,
) -> Result<String, AnyError> {
let search = form_urlencoded::Serializer::new(String::new())
diff --git a/ext/url/urlpattern.rs b/ext/url/urlpattern.rs
index 4e6b4e4a0..99fd21664 100644
--- a/ext/url/urlpattern.rs
+++ b/ext/url/urlpattern.rs
@@ -9,7 +9,6 @@ use urlpattern::quirks::UrlPattern;
#[op]
pub fn op_urlpattern_parse(
- _state: &mut deno_core::OpState,
input: StringOrInit,
base_url: Option<String>,
) -> Result<UrlPattern, AnyError> {
@@ -27,7 +26,6 @@ pub fn op_urlpattern_parse(
#[op]
pub fn op_urlpattern_process_match_input(
- _state: &mut deno_core::OpState,
input: StringOrInit,
base_url: Option<String>,
) -> Result<Option<(MatchInput, quirks::Inputs)>, AnyError> {
diff --git a/ext/web/lib.rs b/ext/web/lib.rs
index 75e619dfe..d199b7bfe 100644
--- a/ext/web/lib.rs
+++ b/ext/web/lib.rs
@@ -121,20 +121,14 @@ pub fn init<P: TimersPermission + 'static>(
}
#[op]
-fn op_base64_decode(
- _: &mut OpState,
- input: String,
-) -> Result<ZeroCopyBuf, AnyError> {
+fn op_base64_decode(input: String) -> Result<ZeroCopyBuf, AnyError> {
let mut input = input.into_bytes();
input.retain(|c| !c.is_ascii_whitespace());
Ok(b64_decode(&input)?.into())
}
#[op]
-fn op_base64_atob(
- _: &mut OpState,
- s: ByteString,
-) -> Result<ByteString, AnyError> {
+fn op_base64_atob(s: ByteString) -> Result<ByteString, AnyError> {
let mut s = s.0;
s.retain(|c| !c.is_ascii_whitespace());
@@ -184,15 +178,12 @@ fn b64_decode(input: &[u8]) -> Result<Vec<u8>, AnyError> {
}
#[op]
-fn op_base64_encode(
- _: &mut OpState,
- s: ZeroCopyBuf,
-) -> Result<String, AnyError> {
+fn op_base64_encode(s: ZeroCopyBuf) -> Result<String, AnyError> {
Ok(b64_encode(&s))
}
#[op]
-fn op_base64_btoa(_: &mut OpState, s: ByteString) -> Result<String, AnyError> {
+fn op_base64_btoa(s: ByteString) -> Result<String, AnyError> {
Ok(b64_encode(&s))
}
@@ -211,10 +202,7 @@ struct DecoderOptions {
}
#[op]
-fn op_encoding_normalize_label(
- _state: &mut OpState,
- label: String,
-) -> Result<String, AnyError> {
+fn op_encoding_normalize_label(label: String) -> Result<String, AnyError> {
let encoding = Encoding::for_label_no_replacement(label.as_bytes())
.ok_or_else(|| {
range_error(format!(
@@ -331,7 +319,6 @@ struct EncodeIntoResult {
#[op]
fn op_encoding_encode_into(
- _state: &mut OpState,
input: String,
mut buffer: ZeroCopyBuf,
) -> Result<EncodeIntoResult, AnyError> {