summaryrefslogtreecommitdiff
path: root/ext/node/ops/zlib/stream.rs
diff options
context:
space:
mode:
Diffstat (limited to 'ext/node/ops/zlib/stream.rs')
-rw-r--r--ext/node/ops/zlib/stream.rs51
1 files changed, 25 insertions, 26 deletions
diff --git a/ext/node/ops/zlib/stream.rs b/ext/node/ops/zlib/stream.rs
index 90cd58ed3..e61c47c1c 100644
--- a/ext/node/ops/zlib/stream.rs
+++ b/ext/node/ops/zlib/stream.rs
@@ -2,19 +2,18 @@
use super::mode::Flush;
use super::mode::Mode;
-use libz_sys as sys;
use std::ffi::c_int;
use std::ops::Deref;
use std::ops::DerefMut;
pub struct StreamWrapper {
- pub strm: sys::z_stream,
+ pub strm: zlib::z_stream,
}
impl Default for StreamWrapper {
fn default() -> Self {
Self {
- strm: sys::z_stream {
+ strm: zlib::z_stream {
next_in: std::ptr::null_mut(),
avail_in: 0,
total_in: 0,
@@ -25,7 +24,7 @@ impl Default for StreamWrapper {
state: std::ptr::null_mut(),
zalloc: super::alloc::zalloc,
zfree: super::alloc::zfree,
- opaque: 0 as sys::voidpf,
+ opaque: 0 as zlib::voidpf,
data_type: 0,
adler: 0,
reserved: 0,
@@ -35,7 +34,7 @@ impl Default for StreamWrapper {
}
impl Deref for StreamWrapper {
- type Target = sys::z_stream;
+ type Target = zlib::z_stream;
fn deref(&self) -> &Self::Target {
&self.strm
@@ -50,14 +49,14 @@ impl DerefMut for StreamWrapper {
impl StreamWrapper {
pub fn reset(&mut self, mode: Mode) -> c_int {
- // SAFETY: `self.strm` is an initialized `z_stream`.
+ // SAFETY: `self.strm` is an initialized `zlib::z_stream`.
unsafe {
match mode {
Mode::Deflate | Mode::Gzip | Mode::DeflateRaw => {
- sys::deflateReset(&mut self.strm)
+ zlib::deflateReset(&mut self.strm)
}
Mode::Inflate | Mode::Gunzip | Mode::InflateRaw | Mode::Unzip => {
- sys::inflateReset(&mut self.strm)
+ zlib::inflateReset(&mut self.strm)
}
Mode::None => unreachable!(),
}
@@ -65,14 +64,14 @@ impl StreamWrapper {
}
pub fn end(&mut self, mode: Mode) {
- // SAFETY: `self.strm` is an initialized `z_stream`.
+ // SAFETY: `self.strm` is an initialized `zlib::z_stream`.
unsafe {
match mode {
Mode::Deflate | Mode::Gzip | Mode::DeflateRaw => {
- sys::deflateEnd(&mut self.strm);
+ zlib::deflateEnd(&mut self.strm);
}
Mode::Inflate | Mode::Gunzip | Mode::InflateRaw | Mode::Unzip => {
- sys::inflateEnd(&mut self.strm);
+ zlib::inflateEnd(&mut self.strm);
}
Mode::None => {}
}
@@ -86,47 +85,47 @@ impl StreamWrapper {
mem_level: c_int,
strategy: c_int,
) -> c_int {
- // SAFETY: `self.strm` is an initialized `z_stream`.
+ // SAFETY: `self.strm` is an initialized `zlib::z_stream`.
unsafe {
- sys::deflateInit2_(
+ zlib::deflateInit2_(
&mut self.strm,
level,
- sys::Z_DEFLATED,
+ zlib::Z_DEFLATED,
window_bits,
mem_level,
strategy,
- sys::zlibVersion(),
- std::mem::size_of::<sys::z_stream>() as i32,
+ zlib::zlibVersion(),
+ std::mem::size_of::<zlib::z_stream>() as i32,
)
}
}
pub fn inflate_init(&mut self, window_bits: c_int) -> c_int {
- // SAFETY: `self.strm` is an initialized `z_stream`.
+ // SAFETY: `self.strm` is an initialized `zlib::z_stream`.
unsafe {
- sys::inflateInit2_(
+ zlib::inflateInit2_(
&mut self.strm,
window_bits,
- sys::zlibVersion(),
- std::mem::size_of::<sys::z_stream>() as i32,
+ zlib::zlibVersion(),
+ std::mem::size_of::<zlib::z_stream>() as i32,
)
}
}
pub fn deflate(&mut self, flush: Flush) -> c_int {
- // SAFETY: `self.strm` is an initialized `z_stream`.
- unsafe { sys::deflate(&mut self.strm, flush as _) }
+ // SAFETY: `self.strm` is an initialized `zlib::z_stream`.
+ unsafe { zlib::deflate(&mut self.strm, flush as _) }
}
pub fn inflate(&mut self, flush: Flush) -> c_int {
- // SAFETY: `self.strm` is an initialized `z_stream`.
- unsafe { sys::inflate(&mut self.strm, flush as _) }
+ // SAFETY: `self.strm` is an initialized `zlib::z_stream`.
+ unsafe { zlib::inflate(&mut self.strm, flush as _) }
}
pub fn inflate_set_dictionary(&mut self, dictionary: &[u8]) -> c_int {
- // SAFETY: `self.strm` is an initialized `z_stream`.
+ // SAFETY: `self.strm` is an initialized `zlib::z_stream`.
unsafe {
- sys::inflateSetDictionary(
+ zlib::inflateSetDictionary(
&mut self.strm,
dictionary.as_ptr() as *const _,
dictionary.len() as _,