Struct fdeflate::Decompressor
source · pub struct Decompressor {
compression: CompressedBlock,
header: BlockHeader,
uncompressed_bytes_left: u16,
buffer: u64,
nbits: u8,
queued_rle: Option<(u8, usize)>,
queued_backref: Option<(usize, usize)>,
last_block: bool,
fixed_table: bool,
state: State,
checksum: Adler32,
ignore_adler32: bool,
}
Expand description
Decompressor for arbitrary zlib streams.
Fields§
§compression: CompressedBlock
State for decoding a compressed block.
header: BlockHeader
§uncompressed_bytes_left: u16
§buffer: u64
§nbits: u8
§queued_rle: Option<(u8, usize)>
§queued_backref: Option<(usize, usize)>
§last_block: bool
§fixed_table: bool
§state: State
§checksum: Adler32
§ignore_adler32: bool
Implementations§
source§impl Decompressor
impl Decompressor
sourcepub fn ignore_adler32(&mut self)
pub fn ignore_adler32(&mut self)
Ignore the checksum at the end of the stream.
fn fill_buffer(&mut self, input: &mut &[u8])
fn peak_bits(&mut self, nbits: u8) -> u64
fn consume_bits(&mut self, nbits: u8)
fn read_block_header( &mut self, remaining_input: &mut &[u8], ) -> Result<(), DecompressionError>
fn read_code_length_codes( &mut self, remaining_input: &mut &[u8], ) -> Result<(), DecompressionError>
fn read_code_lengths( &mut self, remaining_input: &mut &[u8], ) -> Result<(), DecompressionError>
fn build_tables( hlit: usize, code_lengths: &[u8], compression: &mut CompressedBlock, ) -> Result<(), DecompressionError>
fn read_compressed( &mut self, remaining_input: &mut &[u8], output: &mut [u8], output_index: usize, ) -> Result<usize, DecompressionError>
sourcepub fn read(
&mut self,
input: &[u8],
output: &mut [u8],
output_position: usize,
end_of_input: bool,
) -> Result<(usize, usize), DecompressionError>
pub fn read( &mut self, input: &[u8], output: &mut [u8], output_position: usize, end_of_input: bool, ) -> Result<(usize, usize), DecompressionError>
Decompresses a chunk of data.
Returns the number of bytes read from input
and the number of bytes written to output
,
or an error if the deflate stream is not valid. input
is the compressed data. output
is
the buffer to write the decompressed data to, starting at index output_position
.
end_of_input
indicates whether more data may be available in the future.
The contents of output
after output_position
are ignored. However, this function may
write additional data to output
past what is indicated by the return value.
When this function returns Ok
, at least one of the following is true:
- The input is fully consumed.
- The output is full but there are more bytes to output.
- The deflate stream is complete (and
is_done
will return true).
§Panics
This function will panic if output_position
is out of bounds.