]>
git.proxmox.com Git - rustc.git/blob - vendor/gix-features/src/zlib/mod.rs
1 pub use flate2
::{Decompress, Status}
;
3 /// non-streaming interfaces for decompression
5 /// The error returned by various [Inflate methods][super::Inflate]
6 #[derive(Debug, thiserror::Error)]
9 #[error("Could not write all bytes when decompressing content")]
10 WriteInflated(#[from] std::io::Error),
11 #[error("Could not decode zip stream, status was '{0:?}'")]
12 Inflate(#[from] flate2::DecompressError),
13 #[error("The zlib status indicated an error, status was '{0:?}'")]
14 Status(flate2
::Status
),
18 /// Decompress a few bytes of a zlib stream without allocation
20 /// The actual decompressor doing all the work.
21 pub state
: Decompress
,
24 impl Default
for Inflate
{
25 fn default() -> Self {
27 state
: Decompress
::new(true),
33 /// Run the decompressor exactly once. Cannot be run multiple times
34 pub fn once(&mut self, input
: &[u8], out
: &mut [u8]) -> Result
<(flate2
::Status
, usize, usize), inflate
::Error
> {
35 let before_in
= self.state
.total_in();
36 let before_out
= self.state
.total_out();
37 let status
= self.state
.decompress(input
, out
, flate2
::FlushDecompress
::None
)?
;
40 (self.state
.total_in() - before_in
) as usize,
41 (self.state
.total_out() - before_out
) as usize,