fn new(buffer: &[u8]) -> Result<MetadataTableEntry> {
        let mut metadata_table_entry = unsafe { *(buffer.as_ptr() as *mut MetadataTableEntry) };

        let uuid = crate::uuid_from_guid(buffer).map_err(VhdxMetadataError::InvalidUuid)?;
        metadata_table_entry.item_id = uuid;

        if metadata_table_entry.length > METADATA_LENGTH_MAX {
            return Err(VhdxMetadataError::InvalidMetadataLength);
        }

        if metadata_table_entry.length == 0 && metadata_table_entry.offset != 0 {
            return Err(VhdxMetadataError::InvalidMetadataLength);
        }

        if metadata_table_entry.reserved != 0 {
            return Err(VhdxMetadataError::ReservedIsNonZero);
        }

        Ok(metadata_table_entry)
    }
/// Parse one metadata entry from the buffer
Parse one metadata entry from the buffer
Parse one metadata entry from the buffer
fn new(buffer: &[u8]) -> Result<MetadataTableEntry> {
        let mut metadata_table_entry = unsafe { *(buffer.as_ptr() as *mut MetadataTableEntry) };
        let uuid = crate::uuid_from_guid(buffer).map_err(VhdxMetadataError::InvalidUuid)?;
        metadata_table_entry.item_id = uuid;
        if metadata_table_entry.length > METADATA_LENGTH_MAX {
            return Err(VhdxMetadataError::InvalidMetadataLength);
        }
        if metadata_table_entry.length == 0 && metadata_table_entry.offset != 0 {
            return Err(VhdxMetadataError::InvalidMetadataLength);
        }
        if metadata_table_entry.reserved != 0 {
            return Err(VhdxMetadataError::ReservedIsNonZero);
        }
        Ok(metadata_table_entry)
    }
fn new ( buffer : & [ u8 ] ) -> Result < MetadataTableEntry > { let mut metadata_table_entry = unsafe { * ( buffer . as_ptr ( ) as * mut MetadataTableEntry ) } ; let uuid = crate :: uuid_from_guid ( buffer ) . map_err ( VhdxMetadataError :: InvalidUuid ) ? ; metadata_table_entry . item_id = uuid ; if metadata_table_entry . length > METADATA_LENGTH_MAX { return Err ( VhdxMetadataError :: InvalidMetadataLength ) ; } if metadata_table_entry . length == 0 && metadata_table_entry . offset != 0 { return Err ( VhdxMetadataError :: InvalidMetadataLength ) ; } if metadata_table_entry . reserved != 0 { return Err ( VhdxMetadataError :: ReservedIsNonZero ) ; } Ok ( metadata_table_entry ) }
Parse one metadata entry from the buffer
Parse one metadata entry from the buffer
buffer
&[u8]
buffer
&[u8]