pub struct ChunkReader<R: Read + Seek> { /* private fields */ }Expand description
Reader for chunked Data.db files (NB format)
This reader handles NB format Data.db files where:
- No magic number or header exists (file starts with compressed data)
- Each compressed chunk is followed by a 4-byte CRC32 checksum
- CRC32 uses Java’s
java.util.zip.CRC32algorithm (IEEE polynomial 0x04C11DB7) - Checksums are stored in big-endian format
Implementations§
Source§impl<R: Read + Seek> ChunkReader<R>
impl<R: Read + Seek> ChunkReader<R>
Sourcepub fn new(
reader: R,
compression_info: CompressionInfo,
total_file_size: u64,
) -> Self
pub fn new( reader: R, compression_info: CompressionInfo, total_file_size: u64, ) -> Self
Sourcepub fn read_chunk(&mut self, chunk_index: usize) -> Result<Vec<u8>>
pub fn read_chunk(&mut self, chunk_index: usize) -> Result<Vec<u8>>
Read and validate a specific chunk by index
This method:
- Seeks to the chunk offset in Data.db
- Reads the compressed chunk bytes
- Reads the trailing 4-byte CRC32 checksum
- Validates the CRC32 (fail-fast on mismatch)
§Arguments
chunk_index- Zero-based index of the chunk to read
§Returns
Compressed chunk bytes ready for decompression
§Errors
Returns an error if:
- Chunk index is invalid
- I/O error occurs during reading
- CRC32 validation fails
Sourcepub fn chunk_count(&self) -> usize
pub fn chunk_count(&self) -> usize
Get the number of chunks in this file
Sourcepub fn compression_algorithm(&self) -> &str
pub fn compression_algorithm(&self) -> &str
Get the compression algorithm name
Sourcepub fn chunk_length(&self) -> u32
pub fn chunk_length(&self) -> u32
Get the uncompressed chunk size
Auto Trait Implementations§
impl<R> Freeze for ChunkReader<R>where
R: Freeze,
impl<R> RefUnwindSafe for ChunkReader<R>where
R: RefUnwindSafe,
impl<R> Send for ChunkReader<R>where
R: Send,
impl<R> Sync for ChunkReader<R>where
R: Sync,
impl<R> Unpin for ChunkReader<R>where
R: Unpin,
impl<R> UnsafeUnpin for ChunkReader<R>where
R: UnsafeUnpin,
impl<R> UnwindSafe for ChunkReader<R>where
R: UnwindSafe,
Blanket Implementations§
impl<T> Allocation for T
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