pub struct ChunkDecoder { /* private fields */ }Expand description
Stateful chunk decoder — holds bzip2 stream parameters.
Implementations§
Source§impl ChunkDecoder
impl ChunkDecoder
Sourcepub fn from_header(header: &[u8]) -> Result<Self, BlockError>
pub fn from_header(header: &[u8]) -> Result<Self, BlockError>
Create a decoder from the bzip2 stream header (first 4 bytes: BZhN).
Call this once with the first 4 bytes of the file, then use
decode_chunk() repeatedly on subsequent compressed chunks.
Sourcepub fn decode_chunk_segments(
&self,
data: &[u8],
is_last: bool,
) -> Result<(Vec<Vec<u8>>, usize), BlockError>
pub fn decode_chunk_segments( &self, data: &[u8], is_last: bool, ) -> Result<(Vec<Vec<u8>>, usize), BlockError>
Like decode_chunk, but returns each segment’s output separately.
Avoids the single-threaded assembly of a giant Vec — the caller can send each segment to the writer independently.
Returns (segments, bytes_consumed).
Sourcepub fn decode_chunk(
&self,
data: &[u8],
is_last: bool,
) -> Result<(Vec<u8>, usize), BlockError>
pub fn decode_chunk( &self, data: &[u8], is_last: bool, ) -> Result<(Vec<u8>, usize), BlockError>
Decode all complete bzip2 blocks in data.
data is a raw slice of compressed bzip2 data (may include the
4-byte header on first call, or start mid-stream on subsequent calls).
Returns (decompressed_output, bytes_consumed).
decompressed_output: concatenated decoded blocks, in order.bytes_consumed: how many bytes ofdatawere fully decoded. The caller must carrydata[bytes_consumed..]into the next chunk.
If is_last is true, all blocks are decoded (even the last one).
Otherwise the last block is skipped (it may be incomplete).
Auto Trait Implementations§
impl Freeze for ChunkDecoder
impl RefUnwindSafe for ChunkDecoder
impl Send for ChunkDecoder
impl Sync for ChunkDecoder
impl Unpin for ChunkDecoder
impl UnsafeUnpin for ChunkDecoder
impl UnwindSafe for ChunkDecoder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more