fn process_raw_chunk(
        &self,
        cki: &dyn RafsChunkInfo,
        raw_chunk: &[u8],
        chunk: &mut [u8],
    ) -> Result<usize> {
        if cki.is_compressed() {
            compress::decompress(raw_chunk, chunk)?;
        } else if raw_chunk.as_ptr() != chunk.as_ptr() {
            // Sometimes, caller directly put data into consumer provided buffer.
            // Then we don't have to copy data between slices.
            chunk.copy_from_slice(raw_chunk);
        }

        let d_size = cki.decompress_size() as usize;

        if chunk.len() != d_size {
            return Err(eio!(format!(
                "invalid chunk data, expected size: {} != {}",
                d_size,
                chunk.len(),
            )));
        }

        if self.need_validate() && !digest_check(chunk, &cki.block_id(), self.digester()) {
            return Err(eio!(format!(
                "invalid chunk data, expected digest: {}",
                cki.block_id()
            )));
        }

        Ok(chunk.len())
    }
/// Before storing chunk data into blob cache file. We have cook the raw chunk from
/// backend a bit per as to the chunk description as blob cache always saves plain data
/// into cache file rather than compressed.
/// An inside trick is that it tries to directly save data into caller's buffer.
Before storing chunk data into blob cache file. We have cook the raw chunk from
backend a bit per as to the chunk description as blob cache always saves plain data
into cache file rather than compressed.
An inside trick is that it tries to directly save data into caller's buffer.
Before storing chunk data into blob cache file . We have cook the raw chunk from backend a bit per as to the chunk description as blob cache always saves plain data into cache file rather than compressed . An inside trick is that it tries to directly save data into caller ' s buffer .
fn process_raw_chunk(
        &self,
        cki: &dyn RafsChunkInfo,
        raw_chunk: &[u8],
        chunk: &mut [u8],
    ) -> Result<usize> {
        if cki.is_compressed() {
            compress::decompress(raw_chunk, chunk)?;
        } else if raw_chunk.as_ptr() != chunk.as_ptr() {
            // Sometimes, caller directly put data into consumer provided buffer.
            // Then we don't have to copy data between slices.
            chunk.copy_from_slice(raw_chunk);
        }
        let d_size = cki.decompress_size() as usize;
        if chunk.len() != d_size {
            return Err(eio!(format!(
                "invalid chunk data, expected size: {} != {}",
                d_size,
                chunk.len(),
            )));
        }
        if self.need_validate() && !digest_check(chunk, &cki.block_id(), self.digester()) {
            return Err(eio!(format!(
                "invalid chunk data, expected digest: {}",
                cki.block_id()
            )));
        }
        Ok(chunk.len())
    }
fn process_raw_chunk ( & self , cki : & dyn RafsChunkInfo , raw_chunk : & [ u8 ] , chunk : & mut [ u8 ] , ) -> Result < usize > { if cki . is_compressed ( ) { compress :: decompress ( raw_chunk , chunk ) ? ; } else if raw_chunk . as_ptr ( ) != chunk . as_ptr ( ) { // Sometimes, caller directly put data into consumer provided buffer. // Then we don't have to copy data between slices. chunk . copy_from_slice ( raw_chunk ) ; } let d_size = cki . decompress_size ( ) as usize ; if chunk . len ( ) != d_size { return Err ( eio ! ( format ( " " d_size chunk len ( ) ) ) ) ; } if self . need_validate ( ) && ! digest_check ( chunk , & cki . block_id ( ) , self . digester ( ) ) { return Err ( eio ! ( format ( " " cki block_id ( ) ) ) ) ; } Ok ( chunk . len ( ) ) }
Before storing chunk data into blob cache file.
Before storing chunk data into blob cache file .
&self
cki
&dyn RafsChunkInfo
raw_chunk
&[u8]
chunk
&mut [u8]
&self
cki
&dyn RafsChunkInfo
raw_chunk
&[u8]
chunk
&mut [u8]