/rust/registry/src/index.crates.io-1949cf8c6b5b557f/lzma-rs-0.2.0/src/decode/lzbuffer.rs
Line | Count | Source |
1 | | use crate::error; |
2 | | use std::io; |
3 | | |
4 | | pub trait LzBuffer<W> |
5 | | where |
6 | | W: io::Write, |
7 | | { |
8 | | fn len(&self) -> usize; |
9 | | // Retrieve the last byte or return a default |
10 | | fn last_or(&self, lit: u8) -> u8; |
11 | | // Retrieve the n-th last byte |
12 | | fn last_n(&self, dist: usize) -> error::Result<u8>; |
13 | | // Append a literal |
14 | | fn append_literal(&mut self, lit: u8) -> error::Result<()>; |
15 | | // Fetch an LZ sequence (length, distance) from inside the buffer |
16 | | fn append_lz(&mut self, len: usize, dist: usize) -> error::Result<()>; |
17 | | // Get a reference to the output sink |
18 | | fn get_output(&self) -> &W; |
19 | | // Get a mutable reference to the output sink |
20 | | fn get_output_mut(&mut self) -> &mut W; |
21 | | // Consumes this buffer and flushes any data |
22 | | fn finish(self) -> io::Result<W>; |
23 | | // Consumes this buffer without flushing any data |
24 | | fn into_output(self) -> W; |
25 | | } |
26 | | |
27 | | // An accumulating buffer for LZ sequences |
28 | | pub struct LzAccumBuffer<W> |
29 | | where |
30 | | W: io::Write, |
31 | | { |
32 | | stream: W, // Output sink |
33 | | buf: Vec<u8>, // Buffer |
34 | | memlimit: usize, // Buffer memory limit |
35 | | len: usize, // Total number of bytes sent through the buffer |
36 | | } |
37 | | |
38 | | impl<W> LzAccumBuffer<W> |
39 | | where |
40 | | W: io::Write, |
41 | | { |
42 | 0 | pub fn from_stream(stream: W) -> Self { |
43 | 0 | Self::from_stream_with_memlimit(stream, std::usize::MAX) |
44 | 0 | } |
45 | | |
46 | 0 | pub fn from_stream_with_memlimit(stream: W, memlimit: usize) -> Self { |
47 | 0 | Self { |
48 | 0 | stream, |
49 | 0 | buf: Vec::new(), |
50 | 0 | memlimit, |
51 | 0 | len: 0, |
52 | 0 | } |
53 | 0 | } |
54 | | |
55 | | // Append bytes |
56 | 0 | pub fn append_bytes(&mut self, buf: &[u8]) { |
57 | 0 | self.buf.extend_from_slice(buf); |
58 | 0 | self.len += buf.len(); |
59 | 0 | } |
60 | | |
61 | | // Reset the internal dictionary |
62 | 0 | pub fn reset(&mut self) -> io::Result<()> { |
63 | 0 | self.stream.write_all(self.buf.as_slice())?; |
64 | 0 | self.buf.clear(); |
65 | 0 | self.len = 0; |
66 | 0 | Ok(()) |
67 | 0 | } |
68 | | } |
69 | | |
70 | | impl<W> LzBuffer<W> for LzAccumBuffer<W> |
71 | | where |
72 | | W: io::Write, |
73 | | { |
74 | 0 | fn len(&self) -> usize { |
75 | 0 | self.len |
76 | 0 | } |
77 | | |
78 | | // Retrieve the last byte or return a default |
79 | 0 | fn last_or(&self, lit: u8) -> u8 { |
80 | 0 | let buf_len = self.buf.len(); |
81 | 0 | if buf_len == 0 { |
82 | 0 | lit |
83 | | } else { |
84 | 0 | self.buf[buf_len - 1] |
85 | | } |
86 | 0 | } |
87 | | |
88 | | // Retrieve the n-th last byte |
89 | 0 | fn last_n(&self, dist: usize) -> error::Result<u8> { |
90 | 0 | let buf_len = self.buf.len(); |
91 | 0 | if dist > buf_len { |
92 | 0 | return Err(error::Error::LzmaError(format!( |
93 | 0 | "Match distance {} is beyond output size {}", |
94 | 0 | dist, buf_len |
95 | 0 | ))); |
96 | 0 | } |
97 | | |
98 | 0 | Ok(self.buf[buf_len - dist]) |
99 | 0 | } |
100 | | |
101 | | // Append a literal |
102 | 0 | fn append_literal(&mut self, lit: u8) -> error::Result<()> { |
103 | 0 | let new_len = self.len + 1; |
104 | | |
105 | 0 | if new_len > self.memlimit { |
106 | 0 | Err(error::Error::LzmaError(format!( |
107 | 0 | "exceeded memory limit of {}", |
108 | 0 | self.memlimit |
109 | 0 | ))) |
110 | | } else { |
111 | 0 | self.buf.push(lit); |
112 | 0 | self.len = new_len; |
113 | 0 | Ok(()) |
114 | | } |
115 | 0 | } |
116 | | |
117 | | // Fetch an LZ sequence (length, distance) from inside the buffer |
118 | 0 | fn append_lz(&mut self, len: usize, dist: usize) -> error::Result<()> { |
119 | | lzma_debug!("LZ {{ len: {}, dist: {} }}", len, dist); |
120 | 0 | let buf_len = self.buf.len(); |
121 | 0 | if dist > buf_len { |
122 | 0 | return Err(error::Error::LzmaError(format!( |
123 | 0 | "LZ distance {} is beyond output size {}", |
124 | 0 | dist, buf_len |
125 | 0 | ))); |
126 | 0 | } |
127 | | |
128 | 0 | let mut offset = buf_len - dist; |
129 | 0 | for _ in 0..len { |
130 | 0 | let x = self.buf[offset]; |
131 | 0 | self.buf.push(x); |
132 | 0 | offset += 1; |
133 | 0 | } |
134 | 0 | self.len += len; |
135 | 0 | Ok(()) |
136 | 0 | } |
137 | | |
138 | | // Get a reference to the output sink |
139 | 0 | fn get_output(&self) -> &W { |
140 | 0 | &self.stream |
141 | 0 | } |
142 | | |
143 | | // Get a mutable reference to the output sink |
144 | 0 | fn get_output_mut(&mut self) -> &mut W { |
145 | 0 | &mut self.stream |
146 | 0 | } |
147 | | |
148 | | // Consumes this buffer and flushes any data |
149 | 0 | fn finish(mut self) -> io::Result<W> { |
150 | 0 | self.stream.write_all(self.buf.as_slice())?; |
151 | 0 | self.stream.flush()?; |
152 | 0 | Ok(self.stream) |
153 | 0 | } |
154 | | |
155 | | // Consumes this buffer without flushing any data |
156 | 0 | fn into_output(self) -> W { |
157 | 0 | self.stream |
158 | 0 | } |
159 | | } |
160 | | |
161 | | // A circular buffer for LZ sequences |
162 | | pub struct LzCircularBuffer<W> |
163 | | where |
164 | | W: io::Write, |
165 | | { |
166 | | stream: W, // Output sink |
167 | | buf: Vec<u8>, // Circular buffer |
168 | | dict_size: usize, // Length of the buffer |
169 | | memlimit: usize, // Buffer memory limit |
170 | | cursor: usize, // Current position |
171 | | len: usize, // Total number of bytes sent through the buffer |
172 | | } |
173 | | |
174 | | impl<W> LzCircularBuffer<W> |
175 | | where |
176 | | W: io::Write, |
177 | | { |
178 | 61.0k | pub fn from_stream_with_memlimit(stream: W, dict_size: usize, memlimit: usize) -> Self { |
179 | | lzma_info!("Dict size in LZ buffer: {}", dict_size); |
180 | 61.0k | Self { |
181 | 61.0k | stream, |
182 | 61.0k | buf: Vec::new(), |
183 | 61.0k | dict_size, |
184 | 61.0k | memlimit, |
185 | 61.0k | cursor: 0, |
186 | 61.0k | len: 0, |
187 | 61.0k | } |
188 | 61.0k | } Unexecuted instantiation: <lzma_rs::decode::lzbuffer::LzCircularBuffer<std::io::cursor::Cursor<&mut [u8]>>>::from_stream_with_memlimit <lzma_rs::decode::lzbuffer::LzCircularBuffer<suricata_htp::decompressors::BlockingCursor>>::from_stream_with_memlimit Line | Count | Source | 178 | 61.0k | pub fn from_stream_with_memlimit(stream: W, dict_size: usize, memlimit: usize) -> Self { | 179 | | lzma_info!("Dict size in LZ buffer: {}", dict_size); | 180 | 61.0k | Self { | 181 | 61.0k | stream, | 182 | 61.0k | buf: Vec::new(), | 183 | 61.0k | dict_size, | 184 | 61.0k | memlimit, | 185 | 61.0k | cursor: 0, | 186 | 61.0k | len: 0, | 187 | 61.0k | } | 188 | 61.0k | } |
Unexecuted instantiation: <lzma_rs::decode::lzbuffer::LzCircularBuffer<_>>::from_stream_with_memlimit Unexecuted instantiation: <lzma_rs::decode::lzbuffer::LzCircularBuffer<std::io::cursor::Cursor<&mut [u8]>>>::from_stream_with_memlimit |
189 | | |
190 | 90.9M | fn get(&self, index: usize) -> u8 { |
191 | 90.9M | *self.buf.get(index).unwrap_or(&0) |
192 | 90.9M | } Unexecuted instantiation: <lzma_rs::decode::lzbuffer::LzCircularBuffer<std::io::cursor::Cursor<&mut [u8]>>>::get <lzma_rs::decode::lzbuffer::LzCircularBuffer<suricata_htp::decompressors::BlockingCursor>>::get Line | Count | Source | 190 | 90.9M | fn get(&self, index: usize) -> u8 { | 191 | 90.9M | *self.buf.get(index).unwrap_or(&0) | 192 | 90.9M | } |
Unexecuted instantiation: <lzma_rs::decode::lzbuffer::LzCircularBuffer<_>>::get Unexecuted instantiation: <lzma_rs::decode::lzbuffer::LzCircularBuffer<std::io::cursor::Cursor<&mut [u8]>>>::get |
193 | | |
194 | 90.8M | fn set(&mut self, index: usize, value: u8) -> error::Result<()> { |
195 | 90.8M | let new_len = index + 1; |
196 | | |
197 | 90.8M | if self.buf.len() < new_len { |
198 | 89.3M | if new_len <= self.memlimit { |
199 | 89.3M | self.buf.resize(new_len, 0); |
200 | 89.3M | } else { |
201 | 17 | return Err(error::Error::LzmaError(format!( |
202 | 17 | "exceeded memory limit of {}", |
203 | 17 | self.memlimit |
204 | 17 | ))); |
205 | | } |
206 | 1.50M | } |
207 | 90.8M | self.buf[index] = value; |
208 | 90.8M | Ok(()) |
209 | 90.8M | } Unexecuted instantiation: <lzma_rs::decode::lzbuffer::LzCircularBuffer<std::io::cursor::Cursor<&mut [u8]>>>::set <lzma_rs::decode::lzbuffer::LzCircularBuffer<suricata_htp::decompressors::BlockingCursor>>::set Line | Count | Source | 194 | 90.8M | fn set(&mut self, index: usize, value: u8) -> error::Result<()> { | 195 | 90.8M | let new_len = index + 1; | 196 | | | 197 | 90.8M | if self.buf.len() < new_len { | 198 | 89.3M | if new_len <= self.memlimit { | 199 | 89.3M | self.buf.resize(new_len, 0); | 200 | 89.3M | } else { | 201 | 17 | return Err(error::Error::LzmaError(format!( | 202 | 17 | "exceeded memory limit of {}", | 203 | 17 | self.memlimit | 204 | 17 | ))); | 205 | | } | 206 | 1.50M | } | 207 | 90.8M | self.buf[index] = value; | 208 | 90.8M | Ok(()) | 209 | 90.8M | } |
Unexecuted instantiation: <lzma_rs::decode::lzbuffer::LzCircularBuffer<_>>::set Unexecuted instantiation: <lzma_rs::decode::lzbuffer::LzCircularBuffer<std::io::cursor::Cursor<&mut [u8]>>>::set |
210 | | } |
211 | | |
212 | | impl<W> LzBuffer<W> for LzCircularBuffer<W> |
213 | | where |
214 | | W: io::Write, |
215 | | { |
216 | 5.44M | fn len(&self) -> usize { |
217 | 5.44M | self.len |
218 | 5.44M | } Unexecuted instantiation: <lzma_rs::decode::lzbuffer::LzCircularBuffer<std::io::cursor::Cursor<&mut [u8]>> as lzma_rs::decode::lzbuffer::LzBuffer<std::io::cursor::Cursor<&mut [u8]>>>::len <lzma_rs::decode::lzbuffer::LzCircularBuffer<suricata_htp::decompressors::BlockingCursor> as lzma_rs::decode::lzbuffer::LzBuffer<suricata_htp::decompressors::BlockingCursor>>::len Line | Count | Source | 216 | 5.44M | fn len(&self) -> usize { | 217 | 5.44M | self.len | 218 | 5.44M | } |
Unexecuted instantiation: <lzma_rs::decode::lzbuffer::LzCircularBuffer<_> as lzma_rs::decode::lzbuffer::LzBuffer<_>>::len Unexecuted instantiation: <lzma_rs::decode::lzbuffer::LzCircularBuffer<std::io::cursor::Cursor<&mut [u8]>> as lzma_rs::decode::lzbuffer::LzBuffer<std::io::cursor::Cursor<&mut [u8]>>>::len |
219 | | |
220 | | // Retrieve the last byte or return a default |
221 | 1.48M | fn last_or(&self, lit: u8) -> u8 { |
222 | 1.48M | if self.len == 0 { |
223 | 39.2k | lit |
224 | | } else { |
225 | 1.44M | self.get((self.dict_size + self.cursor - 1) % self.dict_size) |
226 | | } |
227 | 1.48M | } Unexecuted instantiation: <lzma_rs::decode::lzbuffer::LzCircularBuffer<std::io::cursor::Cursor<&mut [u8]>> as lzma_rs::decode::lzbuffer::LzBuffer<std::io::cursor::Cursor<&mut [u8]>>>::last_or <lzma_rs::decode::lzbuffer::LzCircularBuffer<suricata_htp::decompressors::BlockingCursor> as lzma_rs::decode::lzbuffer::LzBuffer<suricata_htp::decompressors::BlockingCursor>>::last_or Line | Count | Source | 221 | 1.48M | fn last_or(&self, lit: u8) -> u8 { | 222 | 1.48M | if self.len == 0 { | 223 | 39.2k | lit | 224 | | } else { | 225 | 1.44M | self.get((self.dict_size + self.cursor - 1) % self.dict_size) | 226 | | } | 227 | 1.48M | } |
Unexecuted instantiation: <lzma_rs::decode::lzbuffer::LzCircularBuffer<_> as lzma_rs::decode::lzbuffer::LzBuffer<_>>::last_or Unexecuted instantiation: <lzma_rs::decode::lzbuffer::LzCircularBuffer<std::io::cursor::Cursor<&mut [u8]>> as lzma_rs::decode::lzbuffer::LzBuffer<std::io::cursor::Cursor<&mut [u8]>>>::last_or |
228 | | |
229 | | // Retrieve the n-th last byte |
230 | 66.9k | fn last_n(&self, dist: usize) -> error::Result<u8> { |
231 | 66.9k | if dist > self.dict_size { |
232 | 0 | return Err(error::Error::LzmaError(format!( |
233 | 0 | "Match distance {} is beyond dictionary size {}", |
234 | 0 | dist, self.dict_size |
235 | 0 | ))); |
236 | 66.9k | } |
237 | 66.9k | if dist > self.len { |
238 | 0 | return Err(error::Error::LzmaError(format!( |
239 | 0 | "Match distance {} is beyond output size {}", |
240 | 0 | dist, self.len |
241 | 0 | ))); |
242 | 66.9k | } |
243 | | |
244 | 66.9k | let offset = (self.dict_size + self.cursor - dist) % self.dict_size; |
245 | 66.9k | Ok(self.get(offset)) |
246 | 66.9k | } Unexecuted instantiation: <lzma_rs::decode::lzbuffer::LzCircularBuffer<std::io::cursor::Cursor<&mut [u8]>> as lzma_rs::decode::lzbuffer::LzBuffer<std::io::cursor::Cursor<&mut [u8]>>>::last_n <lzma_rs::decode::lzbuffer::LzCircularBuffer<suricata_htp::decompressors::BlockingCursor> as lzma_rs::decode::lzbuffer::LzBuffer<suricata_htp::decompressors::BlockingCursor>>::last_n Line | Count | Source | 230 | 66.9k | fn last_n(&self, dist: usize) -> error::Result<u8> { | 231 | 66.9k | if dist > self.dict_size { | 232 | 0 | return Err(error::Error::LzmaError(format!( | 233 | 0 | "Match distance {} is beyond dictionary size {}", | 234 | 0 | dist, self.dict_size | 235 | 0 | ))); | 236 | 66.9k | } | 237 | 66.9k | if dist > self.len { | 238 | 0 | return Err(error::Error::LzmaError(format!( | 239 | 0 | "Match distance {} is beyond output size {}", | 240 | 0 | dist, self.len | 241 | 0 | ))); | 242 | 66.9k | } | 243 | | | 244 | 66.9k | let offset = (self.dict_size + self.cursor - dist) % self.dict_size; | 245 | 66.9k | Ok(self.get(offset)) | 246 | 66.9k | } |
Unexecuted instantiation: <lzma_rs::decode::lzbuffer::LzCircularBuffer<_> as lzma_rs::decode::lzbuffer::LzBuffer<_>>::last_n Unexecuted instantiation: <lzma_rs::decode::lzbuffer::LzCircularBuffer<std::io::cursor::Cursor<&mut [u8]>> as lzma_rs::decode::lzbuffer::LzBuffer<std::io::cursor::Cursor<&mut [u8]>>>::last_n |
247 | | |
248 | | // Append a literal |
249 | 90.8M | fn append_literal(&mut self, lit: u8) -> error::Result<()> { |
250 | 90.8M | self.set(self.cursor, lit)?; |
251 | 90.8M | self.cursor += 1; |
252 | 90.8M | self.len += 1; |
253 | | |
254 | | // Flush the circular buffer to the output |
255 | 90.8M | if self.cursor == self.dict_size { |
256 | 673 | self.stream.write_all(self.buf.as_slice())?; |
257 | 418 | self.cursor = 0; |
258 | 90.8M | } |
259 | | |
260 | 90.8M | Ok(()) |
261 | 90.8M | } Unexecuted instantiation: <lzma_rs::decode::lzbuffer::LzCircularBuffer<std::io::cursor::Cursor<&mut [u8]>> as lzma_rs::decode::lzbuffer::LzBuffer<std::io::cursor::Cursor<&mut [u8]>>>::append_literal <lzma_rs::decode::lzbuffer::LzCircularBuffer<suricata_htp::decompressors::BlockingCursor> as lzma_rs::decode::lzbuffer::LzBuffer<suricata_htp::decompressors::BlockingCursor>>::append_literal Line | Count | Source | 249 | 90.8M | fn append_literal(&mut self, lit: u8) -> error::Result<()> { | 250 | 90.8M | self.set(self.cursor, lit)?; | 251 | 90.8M | self.cursor += 1; | 252 | 90.8M | self.len += 1; | 253 | | | 254 | | // Flush the circular buffer to the output | 255 | 90.8M | if self.cursor == self.dict_size { | 256 | 673 | self.stream.write_all(self.buf.as_slice())?; | 257 | 418 | self.cursor = 0; | 258 | 90.8M | } | 259 | | | 260 | 90.8M | Ok(()) | 261 | 90.8M | } |
Unexecuted instantiation: <lzma_rs::decode::lzbuffer::LzCircularBuffer<_> as lzma_rs::decode::lzbuffer::LzBuffer<_>>::append_literal Unexecuted instantiation: <lzma_rs::decode::lzbuffer::LzCircularBuffer<std::io::cursor::Cursor<&mut [u8]>> as lzma_rs::decode::lzbuffer::LzBuffer<std::io::cursor::Cursor<&mut [u8]>>>::append_literal |
262 | | |
263 | | // Fetch an LZ sequence (length, distance) from inside the buffer |
264 | 432k | fn append_lz(&mut self, len: usize, dist: usize) -> error::Result<()> { |
265 | | lzma_debug!("LZ {{ len: {}, dist: {} }}", len, dist); |
266 | 432k | if dist > self.dict_size { |
267 | 2.82k | return Err(error::Error::LzmaError(format!( |
268 | 2.82k | "LZ distance {} is beyond dictionary size {}", |
269 | 2.82k | dist, self.dict_size |
270 | 2.82k | ))); |
271 | 429k | } |
272 | 429k | if dist > self.len { |
273 | 31.3k | return Err(error::Error::LzmaError(format!( |
274 | 31.3k | "LZ distance {} is beyond output size {}", |
275 | 31.3k | dist, self.len |
276 | 31.3k | ))); |
277 | 398k | } |
278 | | |
279 | 398k | let mut offset = (self.dict_size + self.cursor - dist) % self.dict_size; |
280 | 398k | for _ in 0..len { |
281 | 89.4M | let x = self.get(offset); |
282 | 89.4M | self.append_literal(x)?; |
283 | 89.4M | offset += 1; |
284 | 89.4M | if offset == self.dict_size { |
285 | 411 | offset = 0 |
286 | 89.4M | } |
287 | | } |
288 | 397k | Ok(()) |
289 | 432k | } Unexecuted instantiation: <lzma_rs::decode::lzbuffer::LzCircularBuffer<std::io::cursor::Cursor<&mut [u8]>> as lzma_rs::decode::lzbuffer::LzBuffer<std::io::cursor::Cursor<&mut [u8]>>>::append_lz <lzma_rs::decode::lzbuffer::LzCircularBuffer<suricata_htp::decompressors::BlockingCursor> as lzma_rs::decode::lzbuffer::LzBuffer<suricata_htp::decompressors::BlockingCursor>>::append_lz Line | Count | Source | 264 | 432k | fn append_lz(&mut self, len: usize, dist: usize) -> error::Result<()> { | 265 | | lzma_debug!("LZ {{ len: {}, dist: {} }}", len, dist); | 266 | 432k | if dist > self.dict_size { | 267 | 2.82k | return Err(error::Error::LzmaError(format!( | 268 | 2.82k | "LZ distance {} is beyond dictionary size {}", | 269 | 2.82k | dist, self.dict_size | 270 | 2.82k | ))); | 271 | 429k | } | 272 | 429k | if dist > self.len { | 273 | 31.3k | return Err(error::Error::LzmaError(format!( | 274 | 31.3k | "LZ distance {} is beyond output size {}", | 275 | 31.3k | dist, self.len | 276 | 31.3k | ))); | 277 | 398k | } | 278 | | | 279 | 398k | let mut offset = (self.dict_size + self.cursor - dist) % self.dict_size; | 280 | 398k | for _ in 0..len { | 281 | 89.4M | let x = self.get(offset); | 282 | 89.4M | self.append_literal(x)?; | 283 | 89.4M | offset += 1; | 284 | 89.4M | if offset == self.dict_size { | 285 | 411 | offset = 0 | 286 | 89.4M | } | 287 | | } | 288 | 397k | Ok(()) | 289 | 432k | } |
Unexecuted instantiation: <lzma_rs::decode::lzbuffer::LzCircularBuffer<_> as lzma_rs::decode::lzbuffer::LzBuffer<_>>::append_lz Unexecuted instantiation: <lzma_rs::decode::lzbuffer::LzCircularBuffer<std::io::cursor::Cursor<&mut [u8]>> as lzma_rs::decode::lzbuffer::LzBuffer<std::io::cursor::Cursor<&mut [u8]>>>::append_lz |
290 | | |
291 | | // Get a reference to the output sink |
292 | 0 | fn get_output(&self) -> &W { |
293 | 0 | &self.stream |
294 | 0 | } |
295 | | |
296 | | // Get a mutable reference to the output sink |
297 | 109k | fn get_output_mut(&mut self) -> &mut W { |
298 | 109k | &mut self.stream |
299 | 109k | } Unexecuted instantiation: <lzma_rs::decode::lzbuffer::LzCircularBuffer<_> as lzma_rs::decode::lzbuffer::LzBuffer<_>>::get_output_mut <lzma_rs::decode::lzbuffer::LzCircularBuffer<suricata_htp::decompressors::BlockingCursor> as lzma_rs::decode::lzbuffer::LzBuffer<suricata_htp::decompressors::BlockingCursor>>::get_output_mut Line | Count | Source | 297 | 109k | fn get_output_mut(&mut self) -> &mut W { | 298 | 109k | &mut self.stream | 299 | 109k | } |
|
300 | | |
301 | | // Consumes this buffer and flushes any data |
302 | 344 | fn finish(mut self) -> io::Result<W> { |
303 | 344 | if self.cursor > 0 { |
304 | 43 | self.stream.write_all(&self.buf[0..self.cursor])?; |
305 | 43 | self.stream.flush()?; |
306 | 301 | } |
307 | 344 | Ok(self.stream) |
308 | 344 | } Unexecuted instantiation: <lzma_rs::decode::lzbuffer::LzCircularBuffer<std::io::cursor::Cursor<&mut [u8]>> as lzma_rs::decode::lzbuffer::LzBuffer<std::io::cursor::Cursor<&mut [u8]>>>::finish <lzma_rs::decode::lzbuffer::LzCircularBuffer<suricata_htp::decompressors::BlockingCursor> as lzma_rs::decode::lzbuffer::LzBuffer<suricata_htp::decompressors::BlockingCursor>>::finish Line | Count | Source | 302 | 344 | fn finish(mut self) -> io::Result<W> { | 303 | 344 | if self.cursor > 0 { | 304 | 43 | self.stream.write_all(&self.buf[0..self.cursor])?; | 305 | 43 | self.stream.flush()?; | 306 | 301 | } | 307 | 344 | Ok(self.stream) | 308 | 344 | } |
Unexecuted instantiation: <lzma_rs::decode::lzbuffer::LzCircularBuffer<_> as lzma_rs::decode::lzbuffer::LzBuffer<_>>::finish Unexecuted instantiation: <lzma_rs::decode::lzbuffer::LzCircularBuffer<std::io::cursor::Cursor<&mut [u8]>> as lzma_rs::decode::lzbuffer::LzBuffer<std::io::cursor::Cursor<&mut [u8]>>>::finish |
309 | | |
310 | | // Consumes this buffer without flushing any data |
311 | 21.7k | fn into_output(self) -> W { |
312 | 21.7k | self.stream |
313 | 21.7k | } Unexecuted instantiation: <lzma_rs::decode::lzbuffer::LzCircularBuffer<std::io::cursor::Cursor<&mut [u8]>> as lzma_rs::decode::lzbuffer::LzBuffer<std::io::cursor::Cursor<&mut [u8]>>>::into_output <lzma_rs::decode::lzbuffer::LzCircularBuffer<suricata_htp::decompressors::BlockingCursor> as lzma_rs::decode::lzbuffer::LzBuffer<suricata_htp::decompressors::BlockingCursor>>::into_output Line | Count | Source | 311 | 21.7k | fn into_output(self) -> W { | 312 | 21.7k | self.stream | 313 | 21.7k | } |
Unexecuted instantiation: <lzma_rs::decode::lzbuffer::LzCircularBuffer<_> as lzma_rs::decode::lzbuffer::LzBuffer<_>>::into_output Unexecuted instantiation: <lzma_rs::decode::lzbuffer::LzCircularBuffer<std::io::cursor::Cursor<&mut [u8]>> as lzma_rs::decode::lzbuffer::LzBuffer<std::io::cursor::Cursor<&mut [u8]>>>::into_output |
314 | | } |