fn read_by_chunk(
        &self,
        blob_id: &str,
        cki: &dyn RafsChunkInfo,
        chunk: &mut [u8],
    ) -> Result<usize> {
        let c_offset = cki.compress_offset();
        let d_size = cki.decompress_size() as usize;
        let mut d;

        let raw_chunk = if cki.is_compressed() {
            // Need to put compressed data into a temporary buffer so as to perform decompression.
            // TODO: Use a buffer pool for lower latency?
            let c_size = cki.compress_size() as usize;
            d = alloc_buf(c_size);
            d.as_mut_slice()
        } else {
            // We have this unsafe assignment as it can directly store data into call's buffer.
            unsafe { slice::from_raw_parts_mut(chunk.as_mut_ptr(), chunk.len()) }
        };

        self.read_raw_chunk(blob_id, c_offset, raw_chunk)?;
        // Try to validate data just fetched from backend inside.
        self.process_raw_chunk(cki, raw_chunk, chunk)?;

        Ok(d_size)
    }
/// Read a whole chunk directly from *backend*.
/// The fetched chunk could be compressed or not by different compressors.
/// It depends on `cki` how to describe the chunk data.
/// Moreover, chunk data from backend can be validated per as to nydus configuration.
/// Above is not redundant with blob cache's validation given IO path backend -> blobcache
Read a whole chunk directly from *backend*.
The fetched chunk could be compressed or not by different compressors.
It depends on `cki` how to describe the chunk data.
Moreover, chunk data from backend can be validated per as to nydus configuration.
Above is not redundant with blob cache's validation given IO path backend -> blobcache
Read a whole chunk directly from * backend * . The fetched chunk could be compressed or not by different compressors . It depends on ` cki ` how to describe the chunk data . Moreover chunk data from backend can be validated per as to nydus configuration . Above is not redundant with blob cache ' s validation given IO path backend - > blobcache
fn read_by_chunk(
        &self,
        blob_id: &str,
        cki: &dyn RafsChunkInfo,
        chunk: &mut [u8],
    ) -> Result<usize> {
        let c_offset = cki.compress_offset();
        let d_size = cki.decompress_size() as usize;
        let mut d;
        let raw_chunk = if cki.is_compressed() {
            // Need to put compressed data into a temporary buffer so as to perform decompression.
            // TODO: Use a buffer pool for lower latency?
            let c_size = cki.compress_size() as usize;
            d = alloc_buf(c_size);
            d.as_mut_slice()
        } else {
            // We have this unsafe assignment as it can directly store data into call's buffer.
            unsafe { slice::from_raw_parts_mut(chunk.as_mut_ptr(), chunk.len()) }
        };
        self.read_raw_chunk(blob_id, c_offset, raw_chunk)?;
        // Try to validate data just fetched from backend inside.
        self.process_raw_chunk(cki, raw_chunk, chunk)?;
        Ok(d_size)
    }
fn read_by_chunk ( & self , blob_id : & str , cki : & dyn RafsChunkInfo , chunk : & mut [ u8 ] , ) -> Result < usize > { let c_offset = cki . compress_offset ( ) ; let d_size = cki . decompress_size ( ) as usize ; let mut d ; let raw_chunk = if cki . is_compressed ( ) { // Need to put compressed data into a temporary buffer so as to perform decompression. // TODO: Use a buffer pool for lower latency? let c_size = cki . compress_size ( ) as usize ; d = alloc_buf ( c_size ) ; d . as_mut_slice ( ) } else { // We have this unsafe assignment as it can directly store data into call's buffer. unsafe { slice :: from_raw_parts_mut ( chunk . as_mut_ptr ( ) , chunk . len ( ) ) } } ; self . read_raw_chunk ( blob_id , c_offset , raw_chunk ) ? ; // Try to validate data just fetched from backend inside. self . process_raw_chunk ( cki , raw_chunk , chunk ) ? ; Ok ( d_size ) }
Read a whole chunk directly from *backend*.
Read a whole chunk directly from * backend * .
&self
blob_id
&str
cki
&dyn RafsChunkInfo
chunk
&mut [u8]
&self
blob_id
&str
cki
&dyn RafsChunkInfo
chunk
&mut [u8]