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(seek_table: Vec<ChunkInfo>) -> Result<Self, ChunkedArchiveError>
pub fn new(seek_table: Vec<ChunkInfo>) -> Result<Self, ChunkedArchiveError>
Create a new decompressor to decode an archive from a validated seek table.
pub fn seek_table(&self) -> &Vec<ChunkInfo>
pub fn update( &mut self, data: &[u8], chunk_callback: &mut impl FnMut(&[u8]), ) -> Result<(), ChunkedArchiveError>
Auto Trait Implementations§
impl Freeze for ChunkedDecompressor
impl RefUnwindSafe for ChunkedDecompressor
impl Send for ChunkedDecompressor
impl !Sync for ChunkedDecompressor
impl Unpin 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