pub fn collect_bat_entries(
        f: &mut File,
        disk_spec: &DiskSpec,
        bat_entry: &RegionTableEntry,
    ) -> Result<Vec<BatEntry>> {
        let entry_count = BatEntry::calculate_entries(
            disk_spec.block_size,
            disk_spec.virtual_disk_size,
            disk_spec.chunk_ratio,
        );
        if entry_count as usize > (bat_entry.length as usize / size_of::<BatEntry>()) {
            return Err(VhdxBatError::InvalidEntryCount);
        }

        let mut bat: Vec<BatEntry> = Vec::with_capacity(bat_entry.length as usize);
        let offset = bat_entry.file_offset;
        for i in 0..entry_count {
            f.seek(SeekFrom::Start(offset + i * size_of::<u64>() as u64))
                .map_err(VhdxBatError::ReadBat)?;

            let bat_entry = BatEntry(
                f.read_u64::<LittleEndian>()
                    .map_err(VhdxBatError::ReadBat)?,
            );
            bat.insert(i as usize, bat_entry);
        }

        Ok(bat)
    }
// Read all BAT entries presented on the disk and insert them to a vector
Read all BAT entries presented on the disk and insert them to a vector
Read all BAT entries presented on the disk and insert them to a vector
pub fn collect_bat_entries(
        f: &mut File,
        disk_spec: &DiskSpec,
        bat_entry: &RegionTableEntry,
    ) -> Result<Vec<BatEntry>> {
        let entry_count = BatEntry::calculate_entries(
            disk_spec.block_size,
            disk_spec.virtual_disk_size,
            disk_spec.chunk_ratio,
        );
        if entry_count as usize > (bat_entry.length as usize / size_of::<BatEntry>()) {
            return Err(VhdxBatError::InvalidEntryCount);
        }
        let mut bat: Vec<BatEntry> = Vec::with_capacity(bat_entry.length as usize);
        let offset = bat_entry.file_offset;
        for i in 0..entry_count {
            f.seek(SeekFrom::Start(offset + i * size_of::<u64>() as u64))
                .map_err(VhdxBatError::ReadBat)?;
            let bat_entry = BatEntry(
                f.read_u64::<LittleEndian>()
                    .map_err(VhdxBatError::ReadBat)?,
            );
            bat.insert(i as usize, bat_entry);
        }
        Ok(bat)
    }
pub fn collect_bat_entries ( f : & mut File , disk_spec : & DiskSpec , bat_entry : & RegionTableEntry , ) -> Result < Vec < BatEntry > > { let entry_count = BatEntry :: calculate_entries ( disk_spec . block_size , disk_spec . virtual_disk_size , disk_spec . chunk_ratio , ) ; if entry_count as usize > ( bat_entry . length as usize / size_of :: < BatEntry > ( ) ) { return Err ( VhdxBatError :: InvalidEntryCount ) ; } let mut bat : Vec < BatEntry > = Vec :: with_capacity ( bat_entry . length as usize ) ; let offset = bat_entry . file_offset ; for i in 0 .. entry_count { f . seek ( SeekFrom :: Start ( offset + i * size_of :: < u64 > ( ) as u64 ) ) . map_err ( VhdxBatError :: ReadBat ) ? ; let bat_entry = BatEntry ( f . read_u64 :: < LittleEndian > ( ) . map_err ( VhdxBatError :: ReadBat ) ? , ) ; bat . insert ( i as usize , bat_entry ) ; } Ok ( bat ) }
Read all BAT entries presented on the disk and insert them to a vector
Read all BAT entries presented on the disk and insert them to a vector
f
&mut File
disk_spec
&DiskSpec
bat_entry
&RegionTableEntry
f
&mut File
disk_spec
&DiskSpec
bat_entry
&RegionTableEntry