Struct trust_dns::op::message::Message [] [src]

pub struct Message {
    // some fields omitted

The basic request and response datastructure, used for all DNS protocols.


4.1. Format

All communications inside of the domain protocol are carried in a single
format called a message.  The top level format of message is divided
into 5 sections (some of which are empty in certain cases) shown below:

    |        Header            |
    |  Question / Zone         | the question for the name server
    |   Answer  / Prerequisite | RRs answering the question
    | Authority / Update       | RRs pointing toward an authority
    |      Additional          | RRs holding additional information

The header section is always present.  The header includes fields that
specify which of the remaining sections are present, and also specify
whether the message is a query or a response, a standard query or some
other opcode, etc.

The names of the sections after the header are derived from their use in
standard queries.  The question section contains fields that describe a
question to a name server.  These fields are a query type (QTYPE), a
query class (QCLASS), and a query domain name (QNAME).  The last three
sections have the same format: a possibly empty list of concatenated
resource records (RRs).  The answer section contains RRs that answer the
question; the authority section contains RRs that point toward an
authoritative name server; the additional records section contains RRs
which relate to the query, but are not strictly answers for the

By default Message is a Query. Use the Message::as_update() to create and update, or Message::new_update()


impl Message

fn new() -> Self

fn truncate(&self) -> Self

fn id(&mut self, id: u16) -> &mut Self

fn message_type(&mut self, message_type: MessageType) -> &mut Self

fn op_code(&mut self, op_code: OpCode) -> &mut Self

fn authoritative(&mut self, authoritative: bool) -> &mut Self

fn truncated(&mut self, truncated: bool) -> &mut Self

fn recursion_desired(&mut self, recursion_desired: bool) -> &mut Self

fn recursion_available(&mut self, recursion_available: bool) -> &mut Self

fn authentic_data(&mut self, authentic_data: bool) -> &mut Self

fn checking_disabled(&mut self, checking_disabled: bool) -> &mut Self

fn response_code(&mut self, response_code: ResponseCode) -> &mut Self

fn add_query(&mut self, query: Query) -> &mut Self

fn add_answer(&mut self, record: Record) -> &mut Self

fn add_all_answers(&mut self, vector: &[&Record]) -> &mut Self

fn add_name_server(&mut self, record: Record) -> &mut Self

fn add_all_name_servers(&mut self, vector: &[&Record]) -> &mut Self

fn add_additional(&mut self, record: Record) -> &mut Self

fn set_edns(&mut self, edns: Edns)

fn add_sig0(&mut self, record: Record) -> &mut Self

fn get_id(&self) -> u16

see Header::get_id()

fn get_message_type(&self) -> MessageType

see Header::get_message_type()

fn get_op_code(&self) -> OpCode

see Header::get_op_code()

fn is_authoritative(&self) -> bool

see Header::is_authoritative()

fn is_truncated(&self) -> bool

see Header::is_truncated()

fn is_recursion_desired(&self) -> bool

see Header::is_recursion_desired()

fn is_recursion_available(&self) -> bool

see Header::is_recursion_available()

fn is_authentic_data(&self) -> bool

see Header::is_authentic_data()

fn is_checking_disabled(&self) -> bool

see Header::is_checking_disabled()

fn get_response_code(&self) -> ResponseCode

Return value

The ResponseCode, if this is an EDNS message then this will join the section from the OPT record to create the EDNS ResponseCode

fn get_queries(&self) -> &[Query]

Question        Carries the query name and other query parameters.

fn get_answers(&self) -> &[Record]

Answer          Carries RRs which directly answer the query.

fn get_name_servers(&self) -> &[Record]

Authority       Carries RRs which describe other authoritative servers.
                May optionally carry the SOA RR for the authoritative
                data in the answer section.

fn get_additional(&self) -> &[Record]

Additional      Carries RRs which may be helpful in using the RRs in the
                other sections.

fn get_edns(&self) -> Option<&Edns>

RFC 6891, EDNS(0) Extensions, April 2013

6.1.1.  Basic Elements

 An OPT pseudo-RR (sometimes called a meta-RR) MAY be added to the
 additional data section of a request.

 The OPT RR has RR type 41.

 If an OPT record is present in a received request, compliant
 responders MUST include an OPT record in their respective responses.

 An OPT record does not carry any DNS data.  It is used only to
 contain control information pertaining to the question-and-answer
 sequence of a specific transaction.  OPT RRs MUST NOT be cached,
 forwarded, or stored in or loaded from master files.

 The OPT RR MAY be placed anywhere within the additional data section.
 When an OPT RR is included within any DNS message, it MUST be the
 only OPT RR in that message.  If a query message with more than one
 OPT RR is received, a FORMERR (RCODE=1) MUST be returned.  The
 placement flexibility for the OPT RR does not override the need for
 the TSIG or SIG(0) RRs to be the last in the additional section
 whenever they are present.

Return value

Returns the EDNS record if it was found in the additional section.

fn get_max_payload(&self) -> u16

Return value

the max payload value as it's defined in the EDNS section.

fn get_version(&self) -> u8

Return value

the version as defined in the EDNS record

Trait Implementations

impl UpdateMessage for Message

to reduce errors in using the Message struct as an Update, this will do the call throughs to properly do that.

fn get_id(&self) -> u16

fn add_zone(&mut self, query: Query)

fn add_pre_requisite(&mut self, record: Record)

fn add_all_pre_requisites(&mut self, vector: &[&Record])

fn add_update(&mut self, record: Record)

fn add_all_updates(&mut self, vector: &[&Record])

fn add_additional(&mut self, record: Record)

fn get_zones(&self) -> &[Query]

fn get_pre_requisites(&self) -> &[Record]

fn get_updates(&self) -> &[Record]

fn get_additional(&self) -> &[Record]

fn get_sig0(&self) -> &[Record]

fn sign(&mut self, signer: &Signer, inception_time: u32)

impl BinSerializable<Message> for Message

fn read(decoder: &mut BinDecoder) -> DecodeResult<Self>

fn emit(&self, encoder: &mut BinEncoder) -> EncodeResult

Derived Implementations

impl PartialEq for Message

fn eq(&self, __arg_0: &Message) -> bool

fn ne(&self, __arg_0: &Message) -> bool

impl Debug for Message

fn fmt(&self, __arg_0: &mut Formatter) -> Result