pub fn update_header(
        f: &mut File,
        current_header: &Header,
        change_data_guid: bool,
        mut file_write_guid: u128,
        start: u64,
    ) -> Result<Header> {
        let mut buffer = [0u8; HEADER_SIZE as usize];
        let mut data_write_guid = current_header.data_write_guid;

        if change_data_guid {
            data_write_guid = Uuid::new_v4().as_u128();
        }

        if file_write_guid == 0 {
            file_write_guid = current_header.file_write_guid;
        }

        let mut new_header = Header {
            signature: current_header.signature,
            checksum: 0,
            sequence_number: current_header.sequence_number + 1,
            file_write_guid,
            data_write_guid,
            log_guid: current_header.log_guid,
            log_version: current_header.log_version,
            version: current_header.version,
            log_length: current_header.log_length,
            log_offset: current_header.log_offset,
        };

        new_header.get_header_as_buffer(&mut buffer);
        new_header.checksum = crc32c::crc32c(&buffer);
        new_header.get_header_as_buffer(&mut buffer);

        f.seek(SeekFrom::Start(start))
            .map_err(VhdxHeaderError::SeekHeader)?;
        f.write(&buffer).map_err(VhdxHeaderError::WriteHeader)?;

        Ok(new_header)
    }
/// Creates and returns new updated header from the provided current header
Creates and returns new updated header from the provided current header
Creates and returns new updated header from the provided current header
pub fn update_header(
        f: &mut File,
        current_header: &Header,
        change_data_guid: bool,
        mut file_write_guid: u128,
        start: u64,
    ) -> Result<Header> {
        let mut buffer = [0u8; HEADER_SIZE as usize];
        let mut data_write_guid = current_header.data_write_guid;
        if change_data_guid {
            data_write_guid = Uuid::new_v4().as_u128();
        }
        if file_write_guid == 0 {
            file_write_guid = current_header.file_write_guid;
        }
        let mut new_header = Header {
            signature: current_header.signature,
            checksum: 0,
            sequence_number: current_header.sequence_number + 1,
            file_write_guid,
            data_write_guid,
            log_guid: current_header.log_guid,
            log_version: current_header.log_version,
            version: current_header.version,
            log_length: current_header.log_length,
            log_offset: current_header.log_offset,
        };
        new_header.get_header_as_buffer(&mut buffer);
        new_header.checksum = crc32c::crc32c(&buffer);
        new_header.get_header_as_buffer(&mut buffer);
        f.seek(SeekFrom::Start(start))
            .map_err(VhdxHeaderError::SeekHeader)?;
        f.write(&buffer).map_err(VhdxHeaderError::WriteHeader)?;
        Ok(new_header)
    }
pub fn update_header ( f : & mut File , current_header : & Header , change_data_guid : bool , mut file_write_guid : u128 , start : u64 , ) -> Result < Header > { let mut buffer = [ 0u8 ; HEADER_SIZE as usize ] ; let mut data_write_guid = current_header . data_write_guid ; if change_data_guid { data_write_guid = Uuid :: new_v4 ( ) . as_u128 ( ) ; } if file_write_guid == 0 { file_write_guid = current_header . file_write_guid ; } let mut new_header = Header { signature : current_header . signature , checksum : 0 , sequence_number : current_header . sequence_number + 1 , file_write_guid , data_write_guid , log_guid : current_header . log_guid , log_version : current_header . log_version , version : current_header . version , log_length : current_header . log_length , log_offset : current_header . log_offset , } ; new_header . get_header_as_buffer ( & mut buffer ) ; new_header . checksum = crc32c :: crc32c ( & buffer ) ; new_header . get_header_as_buffer ( & mut buffer ) ; f . seek ( SeekFrom :: Start ( start ) ) . map_err ( VhdxHeaderError :: SeekHeader ) ? ; f . write ( & buffer ) . map_err ( VhdxHeaderError :: WriteHeader ) ? ; Ok ( new_header ) }
Creates and returns new updated header from the provided current header
Creates and returns new updated header from the provided current header
f
&mut File
current_header
&Header
change_data_guid
bool
file_write_guid
u128
start
u64
f
&mut File
current_header
&Header
change_data_guid
bool
file_write_guid
u128
start
u64