fn read_header(file: &mut File) -> Result<[AnvilChunkMetadata; REGION_CHUNKS], io::Error> {
        let mut chunks_metadata = [Default::default(); REGION_CHUNKS];
        let mut values = [0u32; REGION_CHUNKS_METADATA_LENGTH];

        for index in 0..REGION_CHUNKS_METADATA_LENGTH {
            values[index] = file.read_u32::<BigEndian>()?;
        }

        for index in 0..REGION_CHUNKS {
            let last_modified_timestamp = values[REGION_CHUNKS + index];
            let offset = values[index];

            let sector_index = offset >> 8;
            let sectors = (offset & 0xFF) as u8;

            let metadata = AnvilChunkMetadata::new(sector_index, sectors, last_modified_timestamp);
            chunks_metadata[index] = metadata;
        }

        return Ok(chunks_metadata);
    }
/// First 8KB of file are header of 1024 offsets and 1024 timestamps.
First 8KB of file are header of 1024 offsets and 1024 timestamps.
First 8KB of file are header of 1024 offsets and 1024 timestamps .
fn read_header(file: &mut File) -> Result<[AnvilChunkMetadata; REGION_CHUNKS], io::Error> {
        let mut chunks_metadata = [Default::default(); REGION_CHUNKS];
        let mut values = [0u32; REGION_CHUNKS_METADATA_LENGTH];
        for index in 0..REGION_CHUNKS_METADATA_LENGTH {
            values[index] = file.read_u32::<BigEndian>()?;
        }
        for index in 0..REGION_CHUNKS {
            let last_modified_timestamp = values[REGION_CHUNKS + index];
            let offset = values[index];
            let sector_index = offset >> 8;
            let sectors = (offset & 0xFF) as u8;
            let metadata = AnvilChunkMetadata::new(sector_index, sectors, last_modified_timestamp);
            chunks_metadata[index] = metadata;
        }
        return Ok(chunks_metadata);
    }
fn read_header ( file : & mut File ) -> Result < [ AnvilChunkMetadata ; REGION_CHUNKS ] , io :: Error > { let mut chunks_metadata = [ Default :: default ( ) ; REGION_CHUNKS ] ; let mut values = [ 0u32 ; REGION_CHUNKS_METADATA_LENGTH ] ; for index in 0 .. REGION_CHUNKS_METADATA_LENGTH { values [ index ] = file . read_u32 :: < BigEndian > ( ) ? ; } for index in 0 .. REGION_CHUNKS { let last_modified_timestamp = values [ REGION_CHUNKS + index ] ; let offset = values [ index ] ; let sector_index = offset >> 8 ; let sectors = ( offset & 0xFF ) as u8 ; let metadata = AnvilChunkMetadata :: new ( sector_index , sectors , last_modified_timestamp ) ; chunks_metadata [ index ] = metadata ; } return Ok ( chunks_metadata ) ; }
First 8KB of file are header of 1024 offsets and 1024 timestamps.
First 8KB of file are header of 1024 offsets and 1024 timestamps .
file
&mut File
file
&mut File