pub struct ChunkedDecompressor { /* private fields */ }Expand description
Streaming decompressor for chunked archives. Example:
// Create a chunked archive:
let data: Vec<u8> = vec![3; 1024];
let compressed = ChunkedArchive::new(&data, /*block_size*/ 8192).serialize().unwrap();
// Verify the header + decode the seek table:
let (seek_table, archive_data) = decode_archive(&compressed, compressed.len())?.unwrap();
let mut decompressed: Vec<u8> = vec![];
let mut on_chunk = |data: &[u8]| { decompressed.extend_from_slice(data); };
let mut decompressor = ChunkedDecompressor(seek_table);
// `on_chunk` is invoked as each slice is made available. Archive can be provided as chunks.
decompressor.update(archive_data, &mut on_chunk);
assert_eq!(data.as_slice(), decompressed.as_slice());Implementations§
Source§impl ChunkedDecompressor
impl ChunkedDecompressor
Sourcepub fn new(decoded_archive: DecodedArchive) -> Result<Self, ChunkedArchiveError>
pub fn new(decoded_archive: DecodedArchive) -> Result<Self, ChunkedArchiveError>
Create a new decompressor to decode an archive from a validated seek table.
Sourcepub fn new_with_error_handler(
decoded_archive: DecodedArchive,
error_handler: Box<dyn Fn(usize, ChunkInfo, &[u8]) + Send + 'static>,
) -> Result<Self, ChunkedArchiveError>
pub fn new_with_error_handler( decoded_archive: DecodedArchive, error_handler: Box<dyn Fn(usize, ChunkInfo, &[u8]) + Send + 'static>, ) -> Result<Self, ChunkedArchiveError>
Creates a new decompressor with an additional error handler invoked when a chunk fails to be decompressed.
pub fn seek_table(&self) -> &Vec<ChunkInfo>
Auto Trait Implementations§
impl Freeze for ChunkedDecompressor
impl !RefUnwindSafe for ChunkedDecompressor
impl Send for ChunkedDecompressor
impl !Sync for ChunkedDecompressor
impl Unpin for ChunkedDecompressor
impl UnsafeUnpin for ChunkedDecompressor
impl !UnwindSafe for ChunkedDecompressor
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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