fn read_raw_chunk(
        &self,
        chunk: &BlobIoChunk,
        buffer: &mut [u8],
        force_validation: bool,
        raw_hook: Option<&dyn Fn(&[u8])>,
    ) -> Result<usize> {
        let mut d;
        let offset = chunk.compress_offset();
        let raw_chunk = if chunk.is_compressed() {
            // Need a scratch buffer to decompress compressed data.
            let c_size = if self.is_stargz() {
                let blob_size = self.blob_size()?;
                let max_size = blob_size.checked_sub(offset).ok_or_else(|| {
                    einval!("chunk compressed offset is bigger than blob file size")
                })?;
                let max_size = cmp::min(max_size, usize::MAX as u64);
                compress::compute_compressed_gzip_size(buffer.len(), max_size as usize)
            } else {
                chunk.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(buffer.as_mut_ptr(), buffer.len()) }
        };

        let size = self.reader().read(raw_chunk, offset).map_err(|e| eio!(e))?;
        if size != raw_chunk.len() {
            return Err(eio!("storage backend returns less data than requested"));
        }

        self.process_raw_chunk(
            chunk.as_base(),
            raw_chunk,
            None,
            buffer,
            chunk.is_compressed(),
            force_validation,
        )?;
        if let Some(hook) = raw_hook {
            hook(raw_chunk)
        }

        Ok(buffer.len())
    }
/// Read a whole chunk directly from the storage backend.
///
/// The fetched chunk data may be compressed or not, which depends chunk information from `chunk`.
/// Moreover, chunk data from backend storage may be validated per user's configuration.
/// Above is not redundant with blob cache's validation given IO path backend -> blobcache
/// `raw_hook` provides caller a chance to read fetched compressed chunk data.
Read a whole chunk directly from the storage backend.
The fetched chunk data may be compressed or not, which depends chunk information from `chunk`.
Moreover, chunk data from backend storage may be validated per user's configuration.
Above is not redundant with blob cache's validation given IO path backend -> blobcache
`raw_hook` provides caller a chance to read fetched compressed chunk data.
Read a whole chunk directly from the storage backend . The fetched chunk data may be compressed or not which depends chunk information from ` chunk ` . Moreover chunk data from backend storage may be validated per user ' s configuration . Above is not redundant with blob cache ' s validation given IO path backend - > blobcache ` raw_hook ` provides caller a chance to read fetched compressed chunk data .
fn read_raw_chunk(
        &self,
        chunk: &BlobIoChunk,
        buffer: &mut [u8],
        force_validation: bool,
        raw_hook: Option<&dyn Fn(&[u8])>,
    ) -> Result<usize> {
        let mut d;
        let offset = chunk.compress_offset();
        let raw_chunk = if chunk.is_compressed() {
            // Need a scratch buffer to decompress compressed data.
            let c_size = if self.is_stargz() {
                let blob_size = self.blob_size()?;
                let max_size = blob_size.checked_sub(offset).ok_or_else(|| {
                    einval!("chunk compressed offset is bigger than blob file size")
                })?;
                let max_size = cmp::min(max_size, usize::MAX as u64);
                compress::compute_compressed_gzip_size(buffer.len(), max_size as usize)
            } else {
                chunk.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(buffer.as_mut_ptr(), buffer.len()) }
        };
        let size = self.reader().read(raw_chunk, offset).map_err(|e| eio!(e))?;
        if size != raw_chunk.len() {
            return Err(eio!("storage backend returns less data than requested"));
        }
        self.process_raw_chunk(
            chunk.as_base(),
            raw_chunk,
            None,
            buffer,
            chunk.is_compressed(),
            force_validation,
        )?;
        if let Some(hook) = raw_hook {
            hook(raw_chunk)
        }
        Ok(buffer.len())
    }
fn read_raw_chunk ( & self , chunk : & BlobIoChunk , buffer : & mut [ u8 ] , force_validation : bool , raw_hook : Option < & dyn Fn ( & [ u8 ] ) > , ) -> Result < usize > { let mut d ; let offset = chunk . compress_offset ( ) ; let raw_chunk = if chunk . is_compressed ( ) { // Need a scratch buffer to decompress compressed data. let c_size = if self . is_stargz ( ) { let blob_size = self . blob_size ( ) ? ; let max_size = blob_size . checked_sub ( offset ) . ok_or_else ( | | { einval ! ( " " ) } ) ? ; let max_size = cmp :: min ( max_size , usize :: MAX as u64 ) ; compress :: compute_compressed_gzip_size ( buffer . len ( ) , max_size as usize ) } else { chunk . 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 ( buffer . as_mut_ptr ( ) , buffer . len ( ) ) } } ; let size = self . reader ( ) . read ( raw_chunk , offset ) . map_err ( | e | eio ! ( e ) ) ? ; if size != raw_chunk . len ( ) { return Err ( eio ! ( " " ) ) ; } self . process_raw_chunk ( chunk . as_base ( ) , raw_chunk , None , buffer , chunk . is_compressed ( ) , force_validation , ) ? ; if let Some ( hook ) = raw_hook { hook ( raw_chunk ) } Ok ( buffer . len ( ) ) }
Read a whole chunk directly from the storage backend.
Read a whole chunk directly from the storage backend .
&self
chunk
&BlobIoChunk
buffer
&mut [u8]
force_validation
bool
raw_hook
Option<&dyn Fn(&[u8])>
&self
chunk
&BlobIoChunk
buffer
&mut [u8]
force_validation
bool
raw_hook
Option<&dyn Fn(&[u8])>