pub fn from_slice(slice: &[u8]) -> Result<MetaDataHeader, MetaDataError> {
        let mut header: MetaDataHeader =
            deserialize_from(&mut Cursor::new(slice))
                .context(DeserializeError {})?;

        if header.header_size != MetaDataHeader::METADATA_HEADER_SIZE {
            return Err(MetaDataError::HeaderSize {
                actual_size: header.header_size,
                expected_size: MetaDataHeader::METADATA_HEADER_SIZE,
            });
        }

        if header.signature != [0x4d, 0x61, 0x79, 0x61, 0x44, 0x61, 0x74, 0x61]
        {
            return Err(MetaDataError::HeaderSignature {});
        }

        let checksum = header.self_checksum;

        if header.checksum() != checksum {
            return Err(MetaDataError::HeaderChecksum {});
        }

        Ok(header)
    }
/// Convert a slice into a MetaDataHeader and validate
Convert a slice into a MetaDataHeader and validate
Convert a slice into a MetaDataHeader and validate
pub fn from_slice(slice: &[u8]) -> Result<MetaDataHeader, MetaDataError> {
        let mut header: MetaDataHeader =
            deserialize_from(&mut Cursor::new(slice))
                .context(DeserializeError {})?;
        if header.header_size != MetaDataHeader::METADATA_HEADER_SIZE {
            return Err(MetaDataError::HeaderSize {
                actual_size: header.header_size,
                expected_size: MetaDataHeader::METADATA_HEADER_SIZE,
            });
        }
        if header.signature != [0x4d, 0x61, 0x79, 0x61, 0x44, 0x61, 0x74, 0x61]
        {
            return Err(MetaDataError::HeaderSignature {});
        }
        let checksum = header.self_checksum;
        if header.checksum() != checksum {
            return Err(MetaDataError::HeaderChecksum {});
        }
        Ok(header)
    }
pub fn from_slice ( slice : & [ u8 ] ) -> Result < MetaDataHeader , MetaDataError > { let mut header : MetaDataHeader = deserialize_from ( & mut Cursor :: new ( slice ) ) . context ( DeserializeError { } ) ? ; if header . header_size != MetaDataHeader :: METADATA_HEADER_SIZE { return Err ( MetaDataError :: HeaderSize { actual_size : header . header_size , expected_size : MetaDataHeader :: METADATA_HEADER_SIZE , } ) ; } if header . signature != [ 0x4d , 0x61 , 0x79 , 0x61 , 0x44 , 0x61 , 0x74 , 0x61 ] { return Err ( MetaDataError :: HeaderSignature { } ) ; } let checksum = header . self_checksum ; if header . checksum ( ) != checksum { return Err ( MetaDataError :: HeaderChecksum { } ) ; } Ok ( header ) }
Convert a slice into a MetaDataHeader and validate
Convert a slice into a MetaDataHeader and validate
slice
&[u8]