async_compression/codec/lzma/
decoder.rs1use 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(u64::MAX),
14 }
15 }
16
17 pub fn with_memlimit(memlimit: u64) -> Self {
18 Self {
19 inner: crate::codec::Xz2Decoder::new(memlimit),
20 }
21 }
22}
23
24impl Decode for LzmaDecoder {
25 fn reinit(&mut self) -> Result<()> {
26 self.inner.reinit()
27 }
28
29 fn decode(
30 &mut self,
31 input: &mut PartialBuffer<impl AsRef<[u8]>>,
32 output: &mut PartialBuffer<impl AsRef<[u8]> + AsMut<[u8]>>,
33 ) -> Result<bool> {
34 self.inner.decode(input, output)
35 }
36
37 fn flush(
38 &mut self,
39 output: &mut PartialBuffer<impl AsRef<[u8]> + AsMut<[u8]>>,
40 ) -> Result<bool> {
41 self.inner.flush(output)
42 }
43
44 fn finish(
45 &mut self,
46 output: &mut PartialBuffer<impl AsRef<[u8]> + AsMut<[u8]>>,
47 ) -> Result<bool> {
48 self.inner.finish(output)
49 }
50}