Struct domain::base::message_builder::AdditionalBuilder
source · pub struct AdditionalBuilder<Target> { /* private fields */ }
Expand description
Builds the additional section of a DNS message.
A value of this type can be acquired by calling the additional
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 additional 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.
A special method exists to make adding an OPT record to the section
easier. The opt
method creates an OptBuilder
and passes it to a
closure. This way, you can add and remove OPT records from additional
builders that are part of another type and cannot be traded in easily.
Once you are finished building the additional section, you can finish the
message via finish
. Additionally, conversions to all other builder
types are available as well.
Implementations§
source§impl<Target: Composer> AdditionalBuilder<Target>
impl<Target: Composer> AdditionalBuilder<Target>
sourcepub fn push(&mut self, record: impl ComposeRecord) -> Result<(), PushError>
pub fn push(&mut self, record: impl ComposeRecord) -> Result<(), PushError>
Appends a record to the additional section.
This methods accepts anything that implements the
ComposeRecord
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, Ttl};
use domain::base::iana::Class;
use domain::rdata::A;
let mut msg = MessageBuilder::new_vec().additional();
let record = Record::new(
Dname::root_ref(), Class::In, Ttl::from_secs(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();
source§impl<Target: Composer> AdditionalBuilder<Target>
impl<Target: Composer> AdditionalBuilder<Target>
sourcepub fn opt<F>(&mut self, op: F) -> Result<(), PushError>
pub fn opt<F>(&mut self, op: F) -> Result<(), PushError>
Appends and builds an OPT record.
The actual building of the record is handled by a closure that
receives an OptBuilder
which can both change the header of the
record and add options.
The method will return whatever the closure returns. In addition, it will return an error if it failed to add the header of the OPT record.
source§impl<Target: Composer> AdditionalBuilder<Target>
impl<Target: Composer> AdditionalBuilder<Target>
§Conversions
Additional conversion methods are available via the Deref
implementation.
sourcepub fn rewind(&mut self)
pub fn rewind(&mut self)
Rewinds to an empty additional section.
All previously added additional records will be lost.
sourcepub fn builder(self) -> MessageBuilder<Target>
pub fn builder(self) -> MessageBuilder<Target>
Converts the additional builder into a message builder.
All questions and records will be dropped and all sections will be empty.
sourcepub fn question(self) -> QuestionBuilder<Target>
pub fn question(self) -> QuestionBuilder<Target>
Converts the additional builder into a question builder.
All answer, authority, and additional records will be dropped. All previously added questions will, however, remain.
sourcepub fn answer(self) -> AnswerBuilder<Target>
pub fn answer(self) -> AnswerBuilder<Target>
Converts the additional builder into an answer builder.
All authority and additional records will be dropped. All questions and answer records will remain.
Converts the additional builder into an authority builder.
All additional records will be dropped. All questions, answer, and authority records will remain.
source§impl<Target: Composer> AdditionalBuilder<Target>
impl<Target: Composer> AdditionalBuilder<Target>
sourcepub fn additional(self) -> AdditionalBuilder<Target>
pub fn additional(self) -> AdditionalBuilder<Target>
Converts the additional builder into an additional builder.
In other words, does absolutely nothing.
sourcepub fn finish(self) -> Target
pub fn finish(self) -> Target
Converts the additional builder into the underlying octets builder.
sourcepub fn into_message(self) -> Message<Target::Octets>where
Target: FreezeBuilder,
pub fn into_message(self) -> Message<Target::Octets>where
Target: FreezeBuilder,
Converts the additional builder into the final message.
The method will return a message atop whatever octets sequence the builder’s octets builder converts into.
source§impl<Target> AdditionalBuilder<Target>
impl<Target> AdditionalBuilder<Target>
sourcepub fn as_builder(&self) -> &MessageBuilder<Target>
pub fn as_builder(&self) -> &MessageBuilder<Target>
Returns a reference to the underlying message builder.
sourcepub fn as_builder_mut(&mut self) -> &mut MessageBuilder<Target>
pub fn as_builder_mut(&mut self) -> &mut MessageBuilder<Target>
Returns a mutable reference to the underlying message builder.
Methods from Deref<Target = MessageBuilder<Target>>§
sourcepub fn counts(&self) -> HeaderCounts
pub fn counts(&self) -> HeaderCounts
Return the current value of the message header counts.
sourcepub fn header_mut(&mut self) -> &mut Header
pub fn header_mut(&mut self) -> &mut Header
Returns a mutable reference to the message header for manipulations.
Trait Implementations§
source§impl<Target> AsMut<MessageBuilder<Target>> for AdditionalBuilder<Target>
impl<Target> AsMut<MessageBuilder<Target>> for AdditionalBuilder<Target>
source§fn as_mut(&mut self) -> &mut MessageBuilder<Target>
fn as_mut(&mut self) -> &mut MessageBuilder<Target>
source§impl<Target> AsRef<MessageBuilder<Target>> for AdditionalBuilder<Target>
impl<Target> AsRef<MessageBuilder<Target>> for AdditionalBuilder<Target>
source§fn as_ref(&self) -> &MessageBuilder<Target>
fn as_ref(&self) -> &MessageBuilder<Target>
source§impl<Target> AsRef<Target> for AdditionalBuilder<Target>
impl<Target> AsRef<Target> for AdditionalBuilder<Target>
source§impl<Target: Clone> Clone for AdditionalBuilder<Target>
impl<Target: Clone> Clone for AdditionalBuilder<Target>
source§fn clone(&self) -> AdditionalBuilder<Target>
fn clone(&self) -> AdditionalBuilder<Target>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more