compression_codecs/zlib/
decoder.rs1use crate::{DecodeV2, FlateDecoder};
2use compression_core::util::{PartialBuffer, WriteBuffer};
3use std::io::Result;
4
5#[derive(Debug)]
6pub struct ZlibDecoder {
7 inner: FlateDecoder,
8}
9impl Default for ZlibDecoder {
10 fn default() -> Self {
11 Self {
12 inner: FlateDecoder::new(true),
13 }
14 }
15}
16impl ZlibDecoder {
17 pub fn new() -> Self {
18 Self::default()
19 }
20}
21
22impl DecodeV2 for ZlibDecoder {
23 fn reinit(&mut self) -> Result<()> {
24 self.inner.reinit()?;
25 Ok(())
26 }
27
28 fn decode(
29 &mut self,
30 input: &mut PartialBuffer<&[u8]>,
31 output: &mut WriteBuffer<'_>,
32 ) -> Result<bool> {
33 self.inner.decode(input, output)
34 }
35
36 fn flush(&mut self, output: &mut WriteBuffer<'_>) -> Result<bool> {
37 self.inner.flush(output)
38 }
39
40 fn finish(&mut self, output: &mut WriteBuffer<'_>) -> Result<bool> {
41 self.inner.finish(output)
42 }
43}