pub struct AnswerBuilder<Target> { /* private fields */ }
Expand description

Builds the answer section of a DNS message.

A value of this type can be acquired by calling the answer method on any other builder type. See the module documentation for an overview of how to build a message.

You can push records to the end of the answer section via the push method. It accepts various things that represent resource records: record values and references, tuples of an owner domain name, a class, TTL, and record data, as well as tuples of just the owner, TTL, and data, assuming the class of IN.

Once you are finished building the answer section, you can progress to the authority section via the authority method or finish the message via finish. Additionally, conversions to all other builder types are available as well.

Implementations

Appends a record to the answer section.

This methods accepts anything that implements the AsRecord trait. Apart from record values and references, this are tuples of the owner domain name, optionally the class (which is taken to be IN if missing), the TTL, and record data.

In other words, you can do the following things:

use domain::base::{Dname, MessageBuilder, Record, Rtype};
use domain::base::iana::Class;
use domain::rdata::A;

let mut msg = MessageBuilder::new_vec().answer();
let record = Record::new(
    Dname::root_ref(), Class::In, 86400, A::from_octets(192, 0, 2, 1)
);
msg.push(&record).unwrap();
msg.push(record).unwrap();
msg.push(
    (Dname::root_ref(), Class::In, 86400, A::from_octets(192, 0, 2, 1))
).unwrap();
msg.push(
    (Dname::root_ref(), 86400, A::from_octets(192, 0, 2, 1))
).unwrap();

Conversions

Additional conversion are available via the Deref implementation.

Rewinds to an empty answer section.

All previously added answers will be lost.

Converts the answer builder into a message builder.

All questions and answers will be dropped and all sections will be empty.

Converts the answer builder into a question builder.

All answers will be dropped. All previously added questions will, however, remain.

Converts the answer builder into an answer builder.

This doesn’t do anything, really.

Converts the answer builder into an authority builder.

Converts the answer builder into an additional builder.

This will leave the authority section empty.

Converts the answer builder into the underlying octets builder.

This will leave the authority and additional sections empty.

Converts the answer builder into the final message.

The method will return a message atop whatever octets sequence the builder’s octets builder converts into.

Returns a reference to the underlying message builder.

Returns a mutable reference to the underlying message builder.

Methods from Deref<Target = MessageBuilder<Target>>

Return the current value of the message header.

Return the current value of the message header counts.

Returns a mutable reference to the message header for manipulations.

Returns a reference to the underlying octets builder.

Returns an octets slice of the octets assembled so far.

Returns a message atop for the octets assembled so far.

This message is atop the octets slices derived from the builder, so it can be created cheaply.

Trait Implementations

Converts this type into a mutable reference of the (usually inferred) input type.

Converts this type into a shared reference of the (usually inferred) input type.

Converts this type into a shared reference of the (usually inferred) input type.

Converts this type into a shared reference of the (usually inferred) input type.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

The resulting type after dereferencing.

Dereferences the value.

Mutably dereferences the value.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Appends a record to a record section. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Available on crate feature tsig only.

The representation of the key returned by the store.

Available on crate feature tsig only.

Tries to find a key in the store. Read more

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.