/// Updates the header to match the specifications of the seeker given in argument.
/// `first_usable_lba`, `last_usable_lba`, `primary_lba`, `backup_lba`, `partition_entry_lba`
/// will be updated after this operation.
Updates the header to match the specifications of the seeker given in argument.
Updates the header to match the specifications of the seeker given in argument .
pub fn update_from<S: ?Sized>(&mut self, seeker: &mut S, sector_size: u64) -> Result<()>
    where
        S: Seek,
    {
        let partition_array_size = (u64::from(self.number_of_partition_entries)
            * u64::from(self.size_of_partition_entry)
            - 1)
            / sector_size
            + 1;
        let len = seeker.seek(SeekFrom::End(0))? / sector_size;
        if self.primary_lba == 1 {
            self.backup_lba = len - 1;
        } else {
            self.primary_lba = len - 1;
        }
        self.last_usable_lba = len - partition_array_size - 1 - 1;
        self.first_usable_lba = 2 + partition_array_size;
        // NOTE: the partition_entry_lba is either 2 either something near the end of the disk.
        //       If it is something near the end of the disk, it means the self object is a backup
        //       GPT header (which is located at the end of the disk) and its partition_entry_lba
        //       must be updated accordingly
        if self.partition_entry_lba != 2 {
            self.partition_entry_lba = self.last_usable_lba + 1;
        }
        Ok(())
    }
pub fn update_from < S : ? Sized > ( & mut self , seeker : & mut S , sector_size : u64 ) -> Result < ( ) > where S : Seek , { let partition_array_size = ( u64 :: from ( self . number_of_partition_entries ) * u64 :: from ( self . size_of_partition_entry ) - 1 ) / sector_size + 1 ; let len = seeker . seek ( SeekFrom :: End ( 0 ) ) ? / sector_size ; if self . primary_lba == 1 { self . backup_lba = len - 1 ; } else { self . primary_lba = len - 1 ; } self . last_usable_lba = len - partition_array_size - 1 - 1 ; self . first_usable_lba = 2 + partition_array_size ; // NOTE: the partition_entry_lba is either 2 either something near the end of the disk. //       If it is something near the end of the disk, it means the self object is a backup //       GPT header (which is located at the end of the disk) and its partition_entry_lba //       must be updated accordingly if self . partition_entry_lba != 2 { self . partition_entry_lba = self . last_usable_lba + 1 ; } Ok ( ( ) ) }
Updates the header to match the specifications of the seeker given in argument.
Updates the header to match the specifications of the seeker given in argument .
&mut self
seeker
&mut S
sector_size
u64