/// Reads an atom header from the provided `ByteStream`.
Reads an atom header from the provided `ByteStream`.
Reads an atom header from the provided ` ByteStream ` .
pub fn read<B: ByteStream>(reader: &mut B) -> Result<AtomHeader> {
        let mut atom_len = u64::from(reader.read_be_u32()?);
        let atype = AtomType::from(reader.read_quad_bytes()?);
        let data_len = match atom_len {
            0 => {
                0
            }
            1 => {
                atom_len = reader.read_be_u64()?;
                // The atom size should be atleast the length of the header.
                if atom_len < AtomHeader::EXTENDED_HEADER_SIZE {
                    return decode_error("atom size is invalid");
                }
                atom_len - AtomHeader::EXTENDED_HEADER_SIZE
            }
            _ => {
                // The atom size should be atleast the length of the header.
                if atom_len < AtomHeader::HEADER_SIZE {
                    dbg!(atom_len);
                    return decode_error("atom size is invalid");
                }
                atom_len - AtomHeader::HEADER_SIZE
            }
        };
        Ok(AtomHeader { atype, atom_len, data_len })
    }
pub fn read < B : ByteStream > ( reader : & mut B ) -> Result < AtomHeader > { let mut atom_len = u64 :: from ( reader . read_be_u32 ( ) ? ) ; let atype = AtomType :: from ( reader . read_quad_bytes ( ) ? ) ; let data_len = match atom_len { 0 => { 0 } 1 => { atom_len = reader . read_be_u64 ( ) ? ; // The atom size should be atleast the length of the header. if atom_len < AtomHeader :: EXTENDED_HEADER_SIZE { return decode_error ( " " ) ; } atom_len - AtomHeader :: EXTENDED_HEADER_SIZE } _ => { // The atom size should be atleast the length of the header. if atom_len < AtomHeader :: HEADER_SIZE { dbg ! ( atom_len ) ; return decode_error ( " " ) ; } atom_len - AtomHeader :: HEADER_SIZE } } ; Ok ( AtomHeader { atype , atom_len , data_len } ) }
Reads an atom header from the provided `ByteStream`.
Reads an atom header from the provided ` ByteStream ` .
reader
&mut B