Skip to main content

decode_segment

Function decode_segment 

Source
pub fn decode_segment(
    data: &[u8],
    start_bit: u64,
    end_bit: u64,
    max_blocksize: u32,
) -> Vec<u8> 
Expand description

Decode a single segment of compressed bzip2 data.

Reads blocks from start_bit (after the 48-bit BLOCK_MAGIC) up to end_bit. Handles pbzip2 concatenated streams (FINAL_MAGIC boundaries).

Zero per-block allocation: decodes directly into the output buffer using decode_block_into(). Only the segment Vec grows (amortised).

This is the lenient entry point kept for backward compatibility: on a decode failure it returns the bytes decoded so far (never panics). Callers that must REJECT a corrupt/tampered stream (the parallel library API and the lbunzip2 CLI) use decode_segment_checked, which surfaces the per-block CRC failure as an error instead of yielding silently-truncated output.