pub struct ZranGenerator<R> { /* private fields */ }Expand description
Struct to generate random access information for OCIv1 image tarballs.
ZranGenerator generates decompression context information to support random access to the
tarball later. It only tracks information related to Tar file content, and ignores all other
tar headers and zlib headers when possible. The work flow is:
- create a
ZranGeneratorobjectzran. - create a tar::Archive object from
zran. - walk all entries in the tarball, for each tar regular file: 3.1) get file size and split it into chunks, for each file data chunk 3.2) call zran.begin_data_chunk() 3.3) read file content from the tar Entry object 3.4) call zran.end_data_chunk() to get chunk decompression information
- call zran.get_compression_info_array() to get all decompression context information for random access later
Implementations§
Source§impl<R: Read> ZranGenerator<R>
impl<R: Read> ZranGenerator<R>
Sourcepub fn new(reader: ZranReader<R>) -> Self
pub fn new(reader: ZranReader<R>) -> Self
Create a new instance of ZranGenerator from a reader.
Sourcepub fn begin_read(&mut self, chunk_size: u64) -> Result<u32>
pub fn begin_read(&mut self, chunk_size: u64) -> Result<u32>
Begin a transaction to read data from the zlib stream.
§Arguments
chunk_size: size of data to be read from the zlib stream.
Sourcepub fn end_read(&mut self) -> Result<ZranChunkInfo>
pub fn end_read(&mut self) -> Result<ZranChunkInfo>
Mark end of a data read operation and returns information to decode data from the random access slice.
Sourcepub fn get_compression_ctx_array(&self) -> &[ZranContext]
pub fn get_compression_ctx_array(&self) -> &[ZranContext]
Get an immutable reference to the random access context information array.
Sourcepub fn set_min_compressed_size(&mut self, sz: u64)
pub fn set_min_compressed_size(&mut self, sz: u64)
Set minimal compressed size to emit an random access slice.
Please ensure “min_compressed_size * 2 <= max_compressed_size”.
Sourcepub fn set_max_compressed_size(&mut self, sz: u64)
pub fn set_max_compressed_size(&mut self, sz: u64)
Set maximum compressed size to emit an random access slice.
Please ensure “min_compressed_size * 2 <= max_compressed_size”.
Sourcepub fn set_max_uncompressed_size(&mut self, sz: u64)
pub fn set_max_uncompressed_size(&mut self, sz: u64)
Set maximum uncompressed size to emit an random access slice.
Please ensure “min_compressed_size * 2 < max_compressed_size”.
Trait Implementations§
Source§impl<R: Read> Read for ZranGenerator<R>
impl<R: Read> Read for ZranGenerator<R>
Source§fn read(&mut self, buf: &mut [u8]) -> Result<usize>
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
1.36.0 · Source§fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
read, except that it reads into a slice of buffers. Read moreSource§fn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
can_vector)1.0.0 · Source§fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
buf. Read more1.0.0 · Source§fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
buf. Read more1.6.0 · Source§fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
buf. Read moreSource§fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
read_buf)Source§fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
read_buf)cursor. Read more1.0.0 · Source§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Read. Read more