diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2023-10-05 14:34:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-05 14:34:38 +0200 |
commit | 5d98a544b421e2b0bc3f99318fe44d1fed6d95d9 (patch) | |
tree | 871b510abadb2746a532ba7a13988f7dc437d932 /ext/web/compression.rs | |
parent | 551a08145098e95022efb778308d677db60a67cc (diff) |
refactor: rewrite several extension ops to op2 (#20457)
Rewrites following extensions:
- `ext/web`
- `ext/url`
- `ext/webstorage`
- `ext/io`
---------
Co-authored-by: Matt Mastracci <matthew@mastracci.com>
Diffstat (limited to 'ext/web/compression.rs')
-rw-r--r-- | ext/web/compression.rs | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/ext/web/compression.rs b/ext/web/compression.rs index 1ebb453b8..ff84b7971 100644 --- a/ext/web/compression.rs +++ b/ext/web/compression.rs @@ -2,7 +2,7 @@ use deno_core::error::type_error; use deno_core::error::AnyError; -use deno_core::op; +use deno_core::op2; use deno_core::OpState; use deno_core::Resource; use deno_core::ResourceId; @@ -39,10 +39,11 @@ impl Resource for CompressionResource { } } -#[op] +#[op2(fast)] +#[smi] pub fn op_compression_new( state: &mut OpState, - format: &str, + #[string] format: &str, is_decoder: bool, ) -> ResourceId { let w = Vec::new(); @@ -65,11 +66,12 @@ pub fn op_compression_new( state.resource_table.add(resource) } -#[op] +#[op2] +#[serde] pub fn op_compression_write( state: &mut OpState, - rid: ResourceId, - input: &[u8], + #[smi] rid: ResourceId, + #[anybuffer] input: &[u8], ) -> Result<ToJsBuffer, AnyError> { let resource = state.resource_table.get::<CompressionResource>(rid)?; let mut inner = resource.0.borrow_mut(); @@ -109,10 +111,11 @@ pub fn op_compression_write( Ok(out.into()) } -#[op] +#[op2] +#[serde] pub fn op_compression_finish( state: &mut OpState, - rid: ResourceId, + #[smi] rid: ResourceId, ) -> Result<ToJsBuffer, AnyError> { let resource = state.resource_table.take::<CompressionResource>(rid)?; let resource = Rc::try_unwrap(resource).unwrap(); |