diff --git a/ext/web/08_text_encoding.js b/ext/web/08_text_encoding.js index 44087b1dea..9e0c1f311c 100644 --- a/ext/web/08_text_encoding.js +++ b/ext/web/08_text_encoding.js @@ -125,24 +125,22 @@ } if (!options.stream && this.#rid === null) { - return ops.op_encoding_decode_single(input, { - label: this.#encoding, - fatal: this.#fatal, - ignoreBom: this.#ignoreBOM, - }); + return ops.op_encoding_decode_single( + input, + this.#encoding, + this.#fatal, + this.#ignoreBOM, + ); } if (this.#rid === null) { - this.#rid = ops.op_encoding_new_decoder({ - label: this.#encoding, - fatal: this.#fatal, - ignoreBom: this.#ignoreBOM, - }); + this.#rid = ops.op_encoding_new_decoder( + this.#encoding, + this.#fatal, + this.#ignoreBOM, + ); } - return ops.op_encoding_decode(input, { - rid: this.#rid, - stream: options.stream, - }); + return ops.op_encoding_decode(input, this.#rid, options.stream); } finally { if (!options.stream && this.#rid !== null) { core.close(this.#rid); diff --git a/ext/web/lib.rs b/ext/web/lib.rs index 91c680f5f1..e71ed6d14b 100644 --- a/ext/web/lib.rs +++ b/ext/web/lib.rs @@ -23,7 +23,6 @@ use encoding_rs::CoderResult; use encoding_rs::Decoder; use encoding_rs::DecoderResult; use encoding_rs::Encoding; -use serde::Deserialize; use serde::Serialize; use std::borrow::Cow; use std::cell::RefCell; @@ -166,14 +165,6 @@ fn forgiving_base64_encode(s: &[u8]) -> String { BASE64_STANDARD.encode_to_boxed_str(s).into_string() } -#[derive(Deserialize)] -#[serde(rename_all = "camelCase")] -struct DecoderOptions { - label: String, - ignore_bom: bool, - fatal: bool, -} - #[op] fn op_encoding_normalize_label(label: String) -> Result { let encoding = Encoding::for_label_no_replacement(label.as_bytes()) @@ -189,14 +180,10 @@ fn op_encoding_normalize_label(label: String) -> Result { #[op] fn op_encoding_decode_single( data: ZeroCopyBuf, - options: DecoderOptions, + label: String, + fatal: bool, + ignore_bom: bool, ) -> Result { - let DecoderOptions { - label, - ignore_bom, - fatal, - } = options; - let encoding = Encoding::for_label(label.as_bytes()).ok_or_else(|| { range_error(format!( "The encoding label provided ('{}') is invalid.", @@ -247,14 +234,10 @@ fn op_encoding_decode_single( #[op] fn op_encoding_new_decoder( state: &mut OpState, - options: DecoderOptions, + label: String, + fatal: bool, + ignore_bom: bool, ) -> Result { - let DecoderOptions { - label, - fatal, - ignore_bom, - } = options; - let encoding = Encoding::for_label(label.as_bytes()).ok_or_else(|| { range_error(format!( "The encoding label provided ('{}') is invalid.", @@ -276,21 +259,13 @@ fn op_encoding_new_decoder( Ok(rid) } -#[derive(Deserialize)] -#[serde(rename_all = "camelCase")] -struct DecodeOptions { - rid: ResourceId, - stream: bool, -} - #[op] fn op_encoding_decode( state: &mut OpState, data: ZeroCopyBuf, - options: DecodeOptions, + rid: ResourceId, + stream: bool, ) -> Result { - let DecodeOptions { rid, stream } = options; - let resource = state.resource_table.get::(rid)?; let mut decoder = resource.decoder.borrow_mut();