/// Read the value without validating.
Read the value without validating.
Read the value without validating .
pub fn read(read: &mut impl Read, meta_data: &MetaData) -> Result<Self> {
        let layer_number = i32_to_usize(
            if meta_data.requirements.is_multilayer() { i32::read(read)? } // documentation says u64, but is i32
            else { 0_i32 }, // reference the first header for single-layer images
            "chunk data part number"
        )?;
        if layer_number >= meta_data.headers.len() {
            return Err(Error::invalid("chunk data part number"));
        }
        let header = &meta_data.headers[layer_number];
        let max_block_byte_size = header.max_block_byte_size();
        let chunk = Chunk {
            layer_index: layer_number,
            compressed_block: match header.blocks {
                // flat data
                BlockDescription::ScanLines if !header.deep => CompressedBlock::ScanLine(CompressedScanLineBlock::read(read, max_block_byte_size)?),
                BlockDescription::Tiles(_) if !header.deep     => CompressedBlock::Tile(CompressedTileBlock::read(read, max_block_byte_size)?),
                // deep data
                BlockDescription::ScanLines   => CompressedBlock::DeepScanLine(CompressedDeepScanLineBlock::read(read, max_block_byte_size)?),
                BlockDescription::Tiles(_)    => CompressedBlock::DeepTile(CompressedDeepTileBlock::read(read, max_block_byte_size)?),
            },
        };
        Ok(chunk)
    }
pub fn read ( read : & mut impl Read , meta_data : & MetaData ) -> Result < Self > { let layer_number = i32_to_usize ( if meta_data . requirements . is_multilayer ( ) { i32 :: read ( read ) ? } // documentation says u64, but is i32 else { 0_i32 } , // reference the first header for single-layer images " " ) ? ; if layer_number >= meta_data . headers . len ( ) { return Err ( Error :: invalid ( " " ) ) ; } let header = & meta_data . headers [ layer_number ] ; let max_block_byte_size = header . max_block_byte_size ( ) ; let chunk = Chunk { layer_index : layer_number , compressed_block : match header . blocks { // flat data BlockDescription :: ScanLines if ! header . deep => CompressedBlock :: ScanLine ( CompressedScanLineBlock :: read ( read , max_block_byte_size ) ? ) , BlockDescription :: Tiles ( _ ) if ! header . deep => CompressedBlock :: Tile ( CompressedTileBlock :: read ( read , max_block_byte_size ) ? ) , // deep data BlockDescription :: ScanLines => CompressedBlock :: DeepScanLine ( CompressedDeepScanLineBlock :: read ( read , max_block_byte_size ) ? ) , BlockDescription :: Tiles ( _ ) => CompressedBlock :: DeepTile ( CompressedDeepTileBlock :: read ( read , max_block_byte_size ) ? ) , } , } ; Ok ( chunk ) }
Read the value without validating.
Read the value without validating .
read
&mut impl Read
meta_data
&MetaData