Struct domain::base::message_builder::AnswerBuilder
source · 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§
source§impl<Target> AnswerBuilder<Target>
impl<Target> AnswerBuilder<Target>
pub fn into_target(self) -> Target
source§impl<Target: Composer> AnswerBuilder<Target>
impl<Target: Composer> AnswerBuilder<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 answer 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::{Name, MessageBuilder, Record, Rtype, Ttl};
use domain::base::iana::Class;
use domain::rdata::A;
let mut msg = MessageBuilder::new_vec().answer();
let record = Record::new(
Name::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(
(Name::root_ref(), Class::IN, 86400, A::from_octets(192, 0, 2, 1))
).unwrap();
msg.push(
(Name::root_ref(), 86400, A::from_octets(192, 0, 2, 1))
).unwrap();
source§impl<Target: Composer> AnswerBuilder<Target>
impl<Target: Composer> AnswerBuilder<Target>
§Conversions
Additional conversion are available via the Deref
implementation.
sourcepub fn rewind(&mut self)
pub fn rewind(&mut self)
Rewinds to an empty answer section.
All previously added answers will be lost.
sourcepub fn builder(self) -> MessageBuilder<Target>
pub fn builder(self) -> MessageBuilder<Target>
Converts the answer builder into a message builder.
All questions and answers will be dropped and all sections will be empty.
sourcepub fn question(self) -> QuestionBuilder<Target>
pub fn question(self) -> QuestionBuilder<Target>
Converts the answer builder into a question builder.
All answers will be dropped. All previously added questions will, however, remain.
source§impl<Target: Composer> AnswerBuilder<Target>
impl<Target: Composer> AnswerBuilder<Target>
sourcepub fn answer(self) -> AnswerBuilder<Target>
pub fn answer(self) -> AnswerBuilder<Target>
Converts the answer builder into an answer builder.
This doesn’t do anything, really.
Converts the answer builder into an authority builder.
sourcepub fn additional(self) -> AdditionalBuilder<Target>
pub fn additional(self) -> AdditionalBuilder<Target>
Converts the answer builder into an additional builder.
This will leave the authority section empty.
source§impl<Target: FreezeBuilder> AnswerBuilder<Target>
impl<Target: FreezeBuilder> AnswerBuilder<Target>
sourcepub fn into_message(self) -> Message<Target::Octets>
pub fn into_message(self) -> Message<Target::Octets>
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.
source§impl<Target> AnswerBuilder<Target>
impl<Target> AnswerBuilder<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 set_push_limit(&mut self, limit: usize)
pub fn set_push_limit(&mut self, limit: usize)
Limit how much of the underlying buffer may be used.
When a limit is set, calling push()
on a message section (e.g.
AdditionalBuilder::push()
) will fail if the limit is exceeded just
as if the actual end of the underlying buffer had been reached.
Note: Calling this function does NOT truncate the underlying buffer.
If the new limit is lees than the amount of the buffer that has
already been used, exisitng content beyond the limit will remain
untouched, the length will remain larger than the limit, and calls to
push()
will fail until the buffer is truncated to a size less than
the limit.
sourcepub fn clear_push_limit(&mut self)
pub fn clear_push_limit(&mut self)
Clear the push limit, if set.
Removes any push limit previously set via [set_push_limit()
].
sourcepub fn push_limit(&self) -> Option<usize>
pub fn push_limit(&self) -> Option<usize>
Returns the current push limit, if set.
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 AnswerBuilder<Target>
impl<Target> AsMut<MessageBuilder<Target>> for AnswerBuilder<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 AnswerBuilder<Target>
impl<Target> AsRef<MessageBuilder<Target>> for AnswerBuilder<Target>
source§fn as_ref(&self) -> &MessageBuilder<Target>
fn as_ref(&self) -> &MessageBuilder<Target>
source§impl<Target> AsRef<Target> for AnswerBuilder<Target>
impl<Target> AsRef<Target> for AnswerBuilder<Target>
source§impl<Target: Clone> Clone for AnswerBuilder<Target>
impl<Target: Clone> Clone for AnswerBuilder<Target>
source§fn clone(&self) -> AnswerBuilder<Target>
fn clone(&self) -> AnswerBuilder<Target>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<Target: Debug> Debug for AnswerBuilder<Target>
impl<Target: Debug> Debug for AnswerBuilder<Target>
source§impl<Target> Deref for AnswerBuilder<Target>
impl<Target> Deref for AnswerBuilder<Target>
source§impl<Target> DerefMut for AnswerBuilder<Target>
impl<Target> DerefMut for AnswerBuilder<Target>
source§impl<Target> From<AdditionalBuilder<Target>> for AnswerBuilder<Target>where
Target: Composer,
impl<Target> From<AdditionalBuilder<Target>> for AnswerBuilder<Target>where
Target: Composer,
source§fn from(src: AdditionalBuilder<Target>) -> Self
fn from(src: AdditionalBuilder<Target>) -> Self
source§impl<Target> From<AnswerBuilder<Target>> for AdditionalBuilder<Target>where
Target: Composer,
impl<Target> From<AnswerBuilder<Target>> for AdditionalBuilder<Target>where
Target: Composer,
source§fn from(src: AnswerBuilder<Target>) -> Self
fn from(src: AnswerBuilder<Target>) -> Self
source§impl<Target> From<AnswerBuilder<Target>> for AuthorityBuilder<Target>where
Target: Composer,
impl<Target> From<AnswerBuilder<Target>> for AuthorityBuilder<Target>where
Target: Composer,
source§fn from(src: AnswerBuilder<Target>) -> Self
fn from(src: AnswerBuilder<Target>) -> Self
source§impl<Target> From<AnswerBuilder<Target>> for Message<Target::Octets>where
Target: FreezeBuilder,
impl<Target> From<AnswerBuilder<Target>> for Message<Target::Octets>where
Target: FreezeBuilder,
source§fn from(src: AnswerBuilder<Target>) -> Self
fn from(src: AnswerBuilder<Target>) -> Self
source§impl<Target> From<AnswerBuilder<Target>> for MessageBuilder<Target>where
Target: Composer,
impl<Target> From<AnswerBuilder<Target>> for MessageBuilder<Target>where
Target: Composer,
source§fn from(src: AnswerBuilder<Target>) -> Self
fn from(src: AnswerBuilder<Target>) -> Self
source§impl<Target> From<AnswerBuilder<Target>> for QuestionBuilder<Target>where
Target: Composer,
impl<Target> From<AnswerBuilder<Target>> for QuestionBuilder<Target>where
Target: Composer,
source§fn from(src: AnswerBuilder<Target>) -> Self
fn from(src: AnswerBuilder<Target>) -> Self
source§impl<Target> From<AuthorityBuilder<Target>> for AnswerBuilder<Target>where
Target: Composer,
impl<Target> From<AuthorityBuilder<Target>> for AnswerBuilder<Target>where
Target: Composer,
source§fn from(src: AuthorityBuilder<Target>) -> Self
fn from(src: AuthorityBuilder<Target>) -> Self
source§impl<Target> From<MessageBuilder<Target>> for AnswerBuilder<Target>where
Target: Composer,
impl<Target> From<MessageBuilder<Target>> for AnswerBuilder<Target>where
Target: Composer,
source§fn from(src: MessageBuilder<Target>) -> Self
fn from(src: MessageBuilder<Target>) -> Self
source§impl<Target> From<QuestionBuilder<Target>> for AnswerBuilder<Target>where
Target: Composer,
impl<Target> From<QuestionBuilder<Target>> for AnswerBuilder<Target>where
Target: Composer,
source§fn from(src: QuestionBuilder<Target>) -> Self
fn from(src: QuestionBuilder<Target>) -> Self
source§impl<Target> RecordSectionBuilder<Target> for AnswerBuilder<Target>where
Target: Composer,
impl<Target> RecordSectionBuilder<Target> for AnswerBuilder<Target>where
Target: Composer,
Auto Trait Implementations§
impl<Target> Freeze for AnswerBuilder<Target>where
Target: Freeze,
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§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)