pub fn question(mut self, qtype: Qtype, qname: &Hostname) -> Result<Self, Error<W5500::Error>> {
        const REMAIN_LEN: u16 = 5;

        if self.writer.remain() < u16::from(qname.len()) + REMAIN_LEN {
            return Err(Error::OutOfMemory);
        }

        for label in qname.labels() {
            // truncation from usize to u8 will not loose precision
            // Hostname is validated to have labels with 63 or fewer bytes
            let label_len: u8 = label.len() as u8;

            self.writer.write_all(&[label_len])?;
            self.writer.write_all(label.as_bytes())?;
        }

        let question_remainder: [u8; REMAIN_LEN as usize] = [
            0, // null terminator for above labels
            qtype.high_byte(),
            qtype.low_byte(),
            Qclass::IN.high_byte(),
            Qclass::IN.low_byte(),
        ];

        self.writer.write_all(&question_remainder)?;

        self.header.increment_qdcount();

        Ok(self)
    }
/// Add a question to the query.
///
/// # References
///
/// * [RFC 1035 Section 4.1.2](https://www.rfc-editor.org/rfc/rfc1035#section-4.1.2)
Add a question to the query.
Add a question to the query .
pub fn question(mut self, qtype: Qtype, qname: &Hostname) -> Result<Self, Error<W5500::Error>> {
        const REMAIN_LEN: u16 = 5;
        if self.writer.remain() < u16::from(qname.len()) + REMAIN_LEN {
            return Err(Error::OutOfMemory);
        }
        for label in qname.labels() {
            // truncation from usize to u8 will not loose precision
            // Hostname is validated to have labels with 63 or fewer bytes
            let label_len: u8 = label.len() as u8;
            self.writer.write_all(&[label_len])?;
            self.writer.write_all(label.as_bytes())?;
        }
        let question_remainder: [u8; REMAIN_LEN as usize] = [
            0, // null terminator for above labels
            qtype.high_byte(),
            qtype.low_byte(),
            Qclass::IN.high_byte(),
            Qclass::IN.low_byte(),
        ];
        self.writer.write_all(&question_remainder)?;
        self.header.increment_qdcount();
        Ok(self)
    }
pub fn question ( mut self , qtype : Qtype , qname : & Hostname ) -> Result < Self , Error < W5500 :: Error > > { const REMAIN_LEN : u16 = 5 ; if self . writer . remain ( ) < u16 :: from ( qname . len ( ) ) + REMAIN_LEN { return Err ( Error :: OutOfMemory ) ; } for label in qname . labels ( ) { // truncation from usize to u8 will not loose precision // Hostname is validated to have labels with 63 or fewer bytes let label_len : u8 = label . len ( ) as u8 ; self . writer . write_all ( & [ label_len ] ) ? ; self . writer . write_all ( label . as_bytes ( ) ) ? ; } let question_remainder : [ u8 ; REMAIN_LEN as usize ] = [ 0 , // null terminator for above labels qtype . high_byte ( ) , qtype . low_byte ( ) , Qclass :: IN . high_byte ( ) , Qclass :: IN . low_byte ( ) , ] ; self . writer . write_all ( & question_remainder ) ? ; self . header . increment_qdcount ( ) ; Ok ( self ) }
Add a question to the query.
Add a question to the query .
mut self
qtype
Qtype
qname
&Hostname
mut self
qtype
Qtype
qname
&Hostname
references
None