fn process_raw_chunk(
        &self,
        chunk: &dyn BlobChunkInfo,
        raw_buffer: &[u8],
        raw_stream: Option<File>,
        buffer: &mut [u8],
        need_decompress: bool,
        force_validation: bool,
    ) -> Result<usize> {
        if need_decompress {
            compress::decompress(raw_buffer, raw_stream, buffer, self.compressor()).map_err(
                |e| {
                    error!("failed to decompress chunk: {}", e);
                    e
                },
            )?;
        } else if raw_buffer.as_ptr() != buffer.as_ptr() {
            // raw_chunk and chunk may point to the same buffer, so only copy data when needed.
            buffer.copy_from_slice(raw_buffer);
        }

        let d_size = chunk.uncompress_size() as usize;
        if buffer.len() != d_size {
            Err(eio!("uncompressed size and buffer size doesn't match"))
        } else if (self.need_validate() || force_validation)
            && !digest_check(buffer, chunk.chunk_id(), self.digester())
        {
            Err(eio!())
        } else {
            Ok(d_size)
        }
    }
/// Hook point to post-process data received from storage backend.
///
/// This hook method provides a chance to transform data received from storage backend into
/// data cached on local disk.
Hook point to post-process data received from storage backend.
This hook method provides a chance to transform data received from storage backend into
data cached on local disk.
Hook point to post - process data received from storage backend . This hook method provides a chance to transform data received from storage backend into data cached on local disk .
fn process_raw_chunk(
        &self,
        chunk: &dyn BlobChunkInfo,
        raw_buffer: &[u8],
        raw_stream: Option<File>,
        buffer: &mut [u8],
        need_decompress: bool,
        force_validation: bool,
    ) -> Result<usize> {
        if need_decompress {
            compress::decompress(raw_buffer, raw_stream, buffer, self.compressor()).map_err(
                |e| {
                    error!("failed to decompress chunk: {}", e);
                    e
                },
            )?;
        } else if raw_buffer.as_ptr() != buffer.as_ptr() {
            // raw_chunk and chunk may point to the same buffer, so only copy data when needed.
            buffer.copy_from_slice(raw_buffer);
        }
        let d_size = chunk.uncompress_size() as usize;
        if buffer.len() != d_size {
            Err(eio!("uncompressed size and buffer size doesn't match"))
        } else if (self.need_validate() || force_validation)
            && !digest_check(buffer, chunk.chunk_id(), self.digester())
        {
            Err(eio!())
        } else {
            Ok(d_size)
        }
    }
fn process_raw_chunk ( & self , chunk : & dyn BlobChunkInfo , raw_buffer : & [ u8 ] , raw_stream : Option < File > , buffer : & mut [ u8 ] , need_decompress : bool , force_validation : bool , ) -> Result < usize > { if need_decompress { compress :: decompress ( raw_buffer , raw_stream , buffer , self . compressor ( ) ) . map_err ( | e | { error ! ( " " e ) ; e } , ) ? ; } else if raw_buffer . as_ptr ( ) != buffer . as_ptr ( ) { // raw_chunk and chunk may point to the same buffer, so only copy data when needed. buffer . copy_from_slice ( raw_buffer ) ; } let d_size = chunk . uncompress_size ( ) as usize ; if buffer . len ( ) != d_size { Err ( eio ! ( " " ) ) } else if ( self . need_validate ( ) || force_validation ) && ! digest_check ( buffer , chunk . chunk_id ( ) , self . digester ( ) ) { Err ( eio ! ( ) ) } else { Ok ( d_size ) } }
Hook point to post-process data received from storage backend.
Hook point to post - process data received from storage backend .
&self
chunk
&dyn BlobChunkInfo
raw_buffer
&[u8]
raw_stream
Option<File>
buffer
&mut [u8]
need_decompress
bool
force_validation
bool
&self
chunk
&dyn BlobChunkInfo
raw_buffer
&[u8]
raw_stream
Option<File>
buffer
&mut [u8]
need_decompress
bool
force_validation
bool