stream_unpack/decompress/
deflate.rs1use std::fmt::Debug;
2
3use inflate::InflateStream;
4
5use super::{Decompressor, DecompressionError};
6
7pub struct DeflateDecompressor(InflateStream);
9
10impl Debug for DeflateDecompressor {
11 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
12 f.debug_struct("DeflateDecompressor")
13 .finish()
14 }
15}
16
17impl Default for DeflateDecompressor {
18 fn default() -> Self {
20 Self::new()
21 }
22}
23
24impl Decompressor for DeflateDecompressor {
25 fn update(&mut self, data: &[u8]) -> Result<(usize, &[u8]), DecompressionError> {
26 self.0.update(data)
27 .map_err(DecompressionError::Generic)
28 }
29}
30
31impl DeflateDecompressor {
32 pub fn new() -> Self {
34 Self(InflateStream::new())
35 }
36}