fn parse(mut self) -> io::Result<Message> {
        self.m.id = self.cur.read_u16::<BE>()?;

        let b = self.cur.read_u8()?;
        self.m.qr = QR::from_bool(0b1000_0000 & b != 0);
        let opcode = (0b0111_1000 & b) >> 3;
        self.m.aa = (0b0000_0100 & b) != 0;
        self.m.tc = (0b0000_0010 & b) != 0;
        self.m.rd = (0b0000_0001 & b) != 0;

        self.m.opcode = match FromPrimitive::from_u8(opcode) {
            Some(t) => t,
            None => bail!(InvalidData, "invalid Opcode({})", opcode),
        };

        let b = self.cur.read_u8()?;
        self.m.ra = (0b1000_0000 & b) != 0;
        self.m.z = (0b0100_0000 & b) != 0; // Unused
        self.m.ad = (0b0010_0000 & b) != 0;
        self.m.cd = (0b0001_0000 & b) != 0;
        let rcode = 0b0000_1111 & b;

        self.m.rcode = match FromPrimitive::from_u8(rcode) {
            Some(t) => t,
            None => bail!(InvalidData, "invalid RCode({})", opcode),
        };

        let qd_count = self.cur.read_u16::<BE>()?;
        let an_count = self.cur.read_u16::<BE>()?;
        let ns_count = self.cur.read_u16::<BE>()?;
        let ar_count = self.cur.read_u16::<BE>()?;

        self.read_questions(qd_count)?;
        self.read_records(an_count, RecordSection::Answers)?;
        self.read_records(ns_count, RecordSection::Authorities)?;
        self.read_records(ar_count, RecordSection::Additionals)?;

        if self.cur.remaining()? > 0 {
            bail!(
                Other,
                "finished parsing with {} bytes left over",
                self.cur.remaining()?
            );
        }

        Ok(self.m)
    }
/// Consume the [`MessageParser`] and returned the resulting Message.
Consume the [`MessageParser`] and returned the resulting Message.
Consume the [ ` MessageParser ` ] and returned the resulting Message .
fn parse(mut self) -> io::Result<Message> {
        self.m.id = self.cur.read_u16::<BE>()?;
        let b = self.cur.read_u8()?;
        self.m.qr = QR::from_bool(0b1000_0000 & b != 0);
        let opcode = (0b0111_1000 & b) >> 3;
        self.m.aa = (0b0000_0100 & b) != 0;
        self.m.tc = (0b0000_0010 & b) != 0;
        self.m.rd = (0b0000_0001 & b) != 0;
        self.m.opcode = match FromPrimitive::from_u8(opcode) {
            Some(t) => t,
            None => bail!(InvalidData, "invalid Opcode({})", opcode),
        };
        let b = self.cur.read_u8()?;
        self.m.ra = (0b1000_0000 & b) != 0;
        self.m.z = (0b0100_0000 & b) != 0; // Unused
        self.m.ad = (0b0010_0000 & b) != 0;
        self.m.cd = (0b0001_0000 & b) != 0;
        let rcode = 0b0000_1111 & b;
        self.m.rcode = match FromPrimitive::from_u8(rcode) {
            Some(t) => t,
            None => bail!(InvalidData, "invalid RCode({})", opcode),
        };
        let qd_count = self.cur.read_u16::<BE>()?;
        let an_count = self.cur.read_u16::<BE>()?;
        let ns_count = self.cur.read_u16::<BE>()?;
        let ar_count = self.cur.read_u16::<BE>()?;
        self.read_questions(qd_count)?;
        self.read_records(an_count, RecordSection::Answers)?;
        self.read_records(ns_count, RecordSection::Authorities)?;
        self.read_records(ar_count, RecordSection::Additionals)?;
        if self.cur.remaining()? > 0 {
            bail!(
                Other,
                "finished parsing with {} bytes left over",
                self.cur.remaining()?
            );
        }
        Ok(self.m)
    }
fn parse ( mut self ) -> io :: Result < Message > { self . m . id = self . cur . read_u16 :: < BE > ( ) ? ; let b = self . cur . read_u8 ( ) ? ; self . m . qr = QR :: from_bool ( 0b1000_0000 & b != 0 ) ; let opcode = ( 0b0111_1000 & b ) >> 3 ; self . m . aa = ( 0b0000_0100 & b ) != 0 ; self . m . tc = ( 0b0000_0010 & b ) != 0 ; self . m . rd = ( 0b0000_0001 & b ) != 0 ; self . m . opcode = match FromPrimitive :: from_u8 ( opcode ) { Some ( t ) => t , None => bail ! ( InvalidData " " opcode ) , } ; let b = self . cur . read_u8 ( ) ? ; self . m . ra = ( 0b1000_0000 & b ) != 0 ; self . m . z = ( 0b0100_0000 & b ) != 0 ; // Unused self . m . ad = ( 0b0010_0000 & b ) != 0 ; self . m . cd = ( 0b0001_0000 & b ) != 0 ; let rcode = 0b0000_1111 & b ; self . m . rcode = match FromPrimitive :: from_u8 ( rcode ) { Some ( t ) => t , None => bail ! ( InvalidData " " opcode ) , } ; let qd_count = self . cur . read_u16 :: < BE > ( ) ? ; let an_count = self . cur . read_u16 :: < BE > ( ) ? ; let ns_count = self . cur . read_u16 :: < BE > ( ) ? ; let ar_count = self . cur . read_u16 :: < BE > ( ) ? ; self . read_questions ( qd_count ) ? ; self . read_records ( an_count , RecordSection :: Answers ) ? ; self . read_records ( ns_count , RecordSection :: Authorities ) ? ; self . read_records ( ar_count , RecordSection :: Additionals ) ? ; if self . cur . remaining ( ) ? > 0 { bail ! ( Other " " self cur remaining ( ) ) ; } Ok ( self . m ) }
Consume the [`MessageParser`] and returned the resulting Message.
Consume the [ ` MessageParser ` ] and returned the resulting Message .
mut self