pub fn new(sector: [u8; 512]) -> Self {
        // fetch all of the values we need
        let revision            = u32::from_ne_bytes(sector[8..12].try_into().unwrap());
        let header_sz           = u32::from_ne_bytes(sector[12..16].try_into().unwrap());
        let crc32               = u32::from_ne_bytes(sector[16..20].try_into().unwrap());
        let curr_lba            = u64::from_ne_bytes(sector[24..32].try_into().unwrap());
        let backup_lba          = u64::from_ne_bytes(sector[32..40].try_into().unwrap());
        let first_lba           = u64::from_ne_bytes(sector[40..48].try_into().unwrap());
        let last_lba            = u64::from_ne_bytes(sector[48..56].try_into().unwrap());
        let lba_part_entries    = u64::from_ne_bytes(sector[72..80].try_into().unwrap());
        let num_partitions      = u32::from_ne_bytes(sector[80..84].try_into().unwrap());
        let part_size           = u32::from_ne_bytes(sector[84..88].try_into().unwrap());
        let part_crc32          = u32::from_ne_bytes(sector[88..92].try_into().unwrap());
        let guid                = bytes_to_guid(sector[56..72].try_into().unwrap());

        // finally we can create the structure
        GPTHeader{
            revision,
            header_sz,
            crc32,
            curr_lba,
            backup_lba,
            first_lba,
            last_lba,
            guid,
            lba_part_entries,
            num_partitions,
            part_size,
            part_crc32
        }
    }
/// creates a new GPTHeader struct from raw bytes 
creates a new GPTHeader struct from raw bytes
creates a new GPTHeader struct from raw bytes
pub fn new(sector: [u8; 512]) -> Self {
        // fetch all of the values we need
        let revision            = u32::from_ne_bytes(sector[8..12].try_into().unwrap());
        let header_sz           = u32::from_ne_bytes(sector[12..16].try_into().unwrap());
        let crc32               = u32::from_ne_bytes(sector[16..20].try_into().unwrap());
        let curr_lba            = u64::from_ne_bytes(sector[24..32].try_into().unwrap());
        let backup_lba          = u64::from_ne_bytes(sector[32..40].try_into().unwrap());
        let first_lba           = u64::from_ne_bytes(sector[40..48].try_into().unwrap());
        let last_lba            = u64::from_ne_bytes(sector[48..56].try_into().unwrap());
        let lba_part_entries    = u64::from_ne_bytes(sector[72..80].try_into().unwrap());
        let num_partitions      = u32::from_ne_bytes(sector[80..84].try_into().unwrap());
        let part_size           = u32::from_ne_bytes(sector[84..88].try_into().unwrap());
        let part_crc32          = u32::from_ne_bytes(sector[88..92].try_into().unwrap());
        let guid                = bytes_to_guid(sector[56..72].try_into().unwrap());
        // finally we can create the structure
        GPTHeader{
            revision,
            header_sz,
            crc32,
            curr_lba,
            backup_lba,
            first_lba,
            last_lba,
            guid,
            lba_part_entries,
            num_partitions,
            part_size,
            part_crc32
        }
    }
pub fn new ( sector : [ u8 ; 512 ] ) -> Self { // fetch all of the values we need let revision = u32 :: from_ne_bytes ( sector [ 8 .. 12 ] . try_into ( ) . unwrap ( ) ) ; let header_sz = u32 :: from_ne_bytes ( sector [ 12 .. 16 ] . try_into ( ) . unwrap ( ) ) ; let crc32 = u32 :: from_ne_bytes ( sector [ 16 .. 20 ] . try_into ( ) . unwrap ( ) ) ; let curr_lba = u64 :: from_ne_bytes ( sector [ 24 .. 32 ] . try_into ( ) . unwrap ( ) ) ; let backup_lba = u64 :: from_ne_bytes ( sector [ 32 .. 40 ] . try_into ( ) . unwrap ( ) ) ; let first_lba = u64 :: from_ne_bytes ( sector [ 40 .. 48 ] . try_into ( ) . unwrap ( ) ) ; let last_lba = u64 :: from_ne_bytes ( sector [ 48 .. 56 ] . try_into ( ) . unwrap ( ) ) ; let lba_part_entries = u64 :: from_ne_bytes ( sector [ 72 .. 80 ] . try_into ( ) . unwrap ( ) ) ; let num_partitions = u32 :: from_ne_bytes ( sector [ 80 .. 84 ] . try_into ( ) . unwrap ( ) ) ; let part_size = u32 :: from_ne_bytes ( sector [ 84 .. 88 ] . try_into ( ) . unwrap ( ) ) ; let part_crc32 = u32 :: from_ne_bytes ( sector [ 88 .. 92 ] . try_into ( ) . unwrap ( ) ) ; let guid = bytes_to_guid ( sector [ 56 .. 72 ] . try_into ( ) . unwrap ( ) ) ; // finally we can create the structure GPTHeader { revision , header_sz , crc32 , curr_lba , backup_lba , first_lba , last_lba , guid , lba_part_entries , num_partitions , part_size , part_crc32 } }
creates a new GPTHeader struct from raw bytes
creates a new GPTHeader struct from raw bytes
sector
[u8; 512]
sector
[u8; 512]