[][src]Struct domain::base::message_builder::AnswerBuilder

pub struct AnswerBuilder<Target> { /* fields omitted */ }

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

impl<Target: OctetsBuilder> AnswerBuilder<Target>[src]

pub fn push(&mut self, record: impl AsRecord) -> Result<(), ShortBuf>[src]

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();

impl<Target: OctetsBuilder> AnswerBuilder<Target>[src]

Conversions

Additional conversion are available via the Deref implementation.

pub fn rewind(&mut self)[src]

Rewinds to an empty answer section.

All previously added answers will be lost.

pub fn builder(self) -> MessageBuilder<Target>[src]

Converts the answer builder into a message builder.

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

pub fn question(self) -> QuestionBuilder<Target>[src]

Converts the answer builder into a question builder.

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

pub fn answer(self) -> AnswerBuilder<Target>[src]

Converts the answer builder into an answer builder.

This doesn’t do anything, really.

pub fn authority(self) -> AuthorityBuilder<Target>[src]

Converts the answer builder into an authority builder.

pub fn additional(self) -> AdditionalBuilder<Target>[src]

Converts the answer builder into an additional builder.

This will leave the authority section empty.

pub fn finish(self) -> Target[src]

Converts the answer builder into the underlying octets builder.

This will leave the authority and additional sections empty.

pub fn into_message(self) -> Message<Target::Octets> where
    Target: IntoOctets
[src]

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.

impl<Target> AnswerBuilder<Target>[src]

pub fn as_builder(&self) -> &MessageBuilder<Target>[src]

Returns a reference to the underlying message builder.

pub fn as_builder_mut(&mut self) -> &mut MessageBuilder<Target>[src]

Returns a mutable reference to the underlying message builder.

Methods from Deref<Target = MessageBuilder<Target>>

pub fn header(&self) -> Header[src]

Return the current value of the message header.

pub fn header_mut(&mut self) -> &mut Header[src]

Returns a mutable reference to the message header for manipulations.

pub fn counts(&self) -> HeaderCounts[src]

Return the current value of the message header counts.

pub fn as_target(&self) -> &Target[src]

Returns a reference to the underlying octets builder.

pub fn as_slice(&self) -> &[u8] where
    Target: AsRef<[u8]>, 
[src]

Returns an octets slice of the octets assembled so far.

pub fn as_message(&self) -> Message<&[u8]> where
    Target: AsRef<[u8]>, 
[src]

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

impl<Target> AsMut<MessageBuilder<Target>> for AnswerBuilder<Target>[src]

impl<Target: AsRef<[u8]>> AsRef<[u8]> for AnswerBuilder<Target>[src]

impl<Target> AsRef<MessageBuilder<Target>> for AnswerBuilder<Target>[src]

impl<Target> AsRef<Target> for AnswerBuilder<Target>[src]

impl<Target: Clone> Clone for AnswerBuilder<Target>[src]

impl<Target: Debug> Debug for AnswerBuilder<Target>[src]

impl<Target> Deref for AnswerBuilder<Target>[src]

type Target = MessageBuilder<Target>

The resulting type after dereferencing.

impl<Target> DerefMut for AnswerBuilder<Target>[src]

impl<Target> From<AdditionalBuilder<Target>> for AnswerBuilder<Target> where
    Target: OctetsBuilder
[src]

impl<Target> From<AnswerBuilder<Target>> for MessageBuilder<Target> where
    Target: OctetsBuilder
[src]

impl<Target> From<AnswerBuilder<Target>> for QuestionBuilder<Target> where
    Target: OctetsBuilder
[src]

impl<Target> From<AnswerBuilder<Target>> for AuthorityBuilder<Target> where
    Target: OctetsBuilder
[src]

impl<Target> From<AnswerBuilder<Target>> for AdditionalBuilder<Target> where
    Target: OctetsBuilder
[src]

impl<Target> From<AuthorityBuilder<Target>> for AnswerBuilder<Target> where
    Target: OctetsBuilder
[src]

impl<Target> From<MessageBuilder<Target>> for AnswerBuilder<Target> where
    Target: OctetsBuilder
[src]

impl<Target> From<QuestionBuilder<Target>> for AnswerBuilder<Target> where
    Target: OctetsBuilder
[src]

impl<Target> RecordSectionBuilder for AnswerBuilder<Target> where
    Target: OctetsBuilder
[src]

Auto Trait Implementations

impl<Target> RefUnwindSafe for AnswerBuilder<Target> where
    Target: RefUnwindSafe

impl<Target> Send for AnswerBuilder<Target> where
    Target: Send

impl<Target> Sync for AnswerBuilder<Target> where
    Target: Sync

impl<Target> Unpin for AnswerBuilder<Target> where
    Target: Unpin

impl<Target> UnwindSafe for AnswerBuilder<Target> where
    Target: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,