Module dns_message_parser::question
source · [−]Expand description
This module contains struct for questions handling.
The Question
struct represents an arbitrary question. Each type has a dedicated enum
variant in the QType
enum.
The QClass
enum represents the class field of the resource record.
The QType
enum represents the type field of the resource record.
Example
use dns_message_parser::question::{Question, QType, QClass};
// Init A record
let question = Question {
// The domain name of the question
domain_name: "example.org".parse().unwrap(),
// The class of the question
q_class: QClass::IN,
// The type of the question
q_type: QType::A,
};
// Encode the A question into bytes::BytesMut
let bytes = question.encode().unwrap();
// Decode the A question into a Question struct
let rr = Question::decode(bytes.freeze()).unwrap();