Skip to main content

async_compression_issue_150_workaround/codec/lzma/
decoder.rs

1use crate::{codec::Decode, util::PartialBuffer};
2
3use std::io::Result;
4
5#[derive(Debug)]
6pub struct LzmaDecoder {
7    inner: crate::codec::Xz2Decoder,
8}
9
10impl LzmaDecoder {
11    pub fn new() -> Self {
12        Self {
13            inner: crate::codec::Xz2Decoder::new(),
14        }
15    }
16}
17
18impl Decode for LzmaDecoder {
19    fn reinit(&mut self) -> Result<()> {
20        self.inner.reinit()
21    }
22
23    fn decode(
24        &mut self,
25        input: &mut PartialBuffer<impl AsRef<[u8]>>,
26        output: &mut PartialBuffer<impl AsRef<[u8]> + AsMut<[u8]>>,
27    ) -> Result<bool> {
28        self.inner.decode(input, output)
29    }
30
31    fn flush(
32        &mut self,
33        output: &mut PartialBuffer<impl AsRef<[u8]> + AsMut<[u8]>>,
34    ) -> Result<bool> {
35        self.inner.flush(output)
36    }
37
38    fn finish(
39        &mut self,
40        output: &mut PartialBuffer<impl AsRef<[u8]> + AsMut<[u8]>>,
41    ) -> Result<bool> {
42        self.inner.finish(output)
43    }
44}