@@ -95,10 +95,10 @@ extern "C" {
95
95
}
96
96
97
97
const LZ_NORM : c_int = 0x80 ; // LZ with 128 probes, "normal"
98
- const TINFL_FLAG_PARSE_ZLIB_HEADER : c_int = 0x1 ; // parse zlib header and adler32 checksum
99
- const TDEFL_WRITE_ZLIB_HEADER : c_int = 0x01000 ; // write zlib header and adler32 checksum
100
98
101
- fn deflate_bytes_internal ( bytes : & [ u8 ] , flags : c_int ) -> Bytes {
99
+ /// Compress a buffer without writing any sort of header on the output.
100
+ pub fn deflate_bytes ( bytes : & [ u8 ] ) -> Bytes {
101
+ let flags = LZ_NORM ;
102
102
unsafe {
103
103
let mut outsz: size_t = 0 ;
104
104
let res = tdefl_compress_mem_to_heap ( bytes. as_ptr ( ) as * const _ ,
@@ -113,17 +113,9 @@ fn deflate_bytes_internal(bytes: &[u8], flags: c_int) -> Bytes {
113
113
}
114
114
}
115
115
116
- /// Compress a buffer, without writing any sort of header on the output.
117
- pub fn deflate_bytes ( bytes : & [ u8 ] ) -> Bytes {
118
- deflate_bytes_internal ( bytes, LZ_NORM )
119
- }
120
-
121
- /// Compress a buffer, using a header that zlib can understand.
122
- pub fn deflate_bytes_zlib ( bytes : & [ u8 ] ) -> Bytes {
123
- deflate_bytes_internal ( bytes, LZ_NORM | TDEFL_WRITE_ZLIB_HEADER )
124
- }
125
-
126
- fn inflate_bytes_internal ( bytes : & [ u8 ] , flags : c_int ) -> Result < Bytes , Error > {
116
+ /// Decompress a buffer without parsing any sort of header on the input.
117
+ pub fn inflate_bytes ( bytes : & [ u8 ] ) -> Result < Bytes , Error > {
118
+ let flags = 0 ;
127
119
unsafe {
128
120
let mut outsz: size_t = 0 ;
129
121
let res = tinfl_decompress_mem_to_heap ( bytes. as_ptr ( ) as * const _ ,
@@ -141,16 +133,6 @@ fn inflate_bytes_internal(bytes: &[u8], flags: c_int) -> Result<Bytes, Error> {
141
133
}
142
134
}
143
135
144
- /// Decompress a buffer, without parsing any sort of header on the input.
145
- pub fn inflate_bytes ( bytes : & [ u8 ] ) -> Result < Bytes , Error > {
146
- inflate_bytes_internal ( bytes, 0 )
147
- }
148
-
149
- /// Decompress a buffer that starts with a zlib header.
150
- pub fn inflate_bytes_zlib ( bytes : & [ u8 ] ) -> Result < Bytes , Error > {
151
- inflate_bytes_internal ( bytes, TINFL_FLAG_PARSE_ZLIB_HEADER )
152
- }
153
-
154
136
#[ cfg( test) ]
155
137
mod tests {
156
138
#![ allow( deprecated) ]
0 commit comments