Struct domain::base::message_builder::QuestionBuilder
source · [−]pub struct QuestionBuilder<Target> { /* private fields */ }
Expand description
Builds the question section of a DNS message.
A value of this type can be acquired by calling the question
method on
any other builder type. See the module documentation for an overview of
how to build a message.
You can push questions to the end of the question section via the
push
method. It accepts various things that represent a question:
question values and references; tuples of a domain name, record type, and
class; and, using the regular class of IN, a pair of just a domain name
and record type.
Once you are finished building the question section, you can progress to
the answer section via the answer
method or finish the message via
finish
. Additionally, conversions to all other builder types are
available as well.
Implementations
sourceimpl<Target: OctetsBuilder + AsMut<[u8]>> QuestionBuilder<Target>
impl<Target: OctetsBuilder + AsMut<[u8]>> QuestionBuilder<Target>
sourcepub fn push(&mut self, question: impl AsQuestion) -> Result<(), ShortBuf>
pub fn push(&mut self, question: impl AsQuestion) -> Result<(), ShortBuf>
Appends a question to the question section.
This method accepts anything that implements the AsQuestion
trait. Apart from an actual Question
or a reference to it, this
can also be a tuple of a domain name, record type, and class or, if
the class is the usual IN, a pair of just the name and type.
In other words, the options are:
use domain::base::{Dname, MessageBuilder, Question, Rtype};
use domain::base::iana::Class;
let mut msg = MessageBuilder::new_vec().question();
msg.push(Question::new_in(Dname::root_ref(), Rtype::A)).unwrap();
msg.push(&Question::new_in(Dname::root_ref(), Rtype::A)).unwrap();
msg.push((Dname::root_ref(), Rtype::A, Class::In)).unwrap();
msg.push((Dname::root_ref(), Rtype::A)).unwrap();
sourceimpl<Target: OctetsBuilder + AsMut<[u8]>> QuestionBuilder<Target>
impl<Target: OctetsBuilder + AsMut<[u8]>> QuestionBuilder<Target>
Conversions
Additional conversion are available via the Deref
implementation.
sourcepub fn rewind(&mut self)
pub fn rewind(&mut self)
Rewinds to an empty question section.
All previously added questions will be lost.
sourcepub fn builder(self) -> MessageBuilder<Target>
pub fn builder(self) -> MessageBuilder<Target>
Converts the question builder into a message builder.
All questions will be dropped and the question section will be empty.
sourceimpl<Target: OctetsBuilder> QuestionBuilder<Target>
impl<Target: OctetsBuilder> QuestionBuilder<Target>
sourcepub fn question(self) -> QuestionBuilder<Target>
pub fn question(self) -> QuestionBuilder<Target>
Converts the question builder into a question builder.
In other words, doesn’t do anything.
sourcepub fn answer(self) -> AnswerBuilder<Target>
pub fn answer(self) -> AnswerBuilder<Target>
Converts the question builder into an answer builder.
Converts the question builder into an authority builder.
This will leave the answer section empty.
sourcepub fn additional(self) -> AdditionalBuilder<Target>
pub fn additional(self) -> AdditionalBuilder<Target>
Converts the question builder into an additional builder.
This will leave the answer and authority sections empty.
sourcepub fn finish(self) -> Target
pub fn finish(self) -> Target
Converts the question builder into the underlying octets builder.
This will leave the answer, authority, and additional sections empty.
sourcepub fn into_message(self) -> Message<Target::Octets>
pub fn into_message(self) -> Message<Target::Octets>
Converts the question builder into the final message.
The method will return a message atop whatever octets sequence the builder’s octets builder converts into.
sourceimpl<Target> QuestionBuilder<Target>
impl<Target> QuestionBuilder<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
sourceimpl<Target> AsMut<MessageBuilder<Target>> for QuestionBuilder<Target>
impl<Target> AsMut<MessageBuilder<Target>> for QuestionBuilder<Target>
sourcefn as_mut(&mut self) -> &mut MessageBuilder<Target>
fn as_mut(&mut self) -> &mut MessageBuilder<Target>
Converts this type into a mutable reference of the (usually inferred) input type.
sourceimpl<Target> AsRef<MessageBuilder<Target>> for QuestionBuilder<Target>
impl<Target> AsRef<MessageBuilder<Target>> for QuestionBuilder<Target>
sourcefn as_ref(&self) -> &MessageBuilder<Target>
fn as_ref(&self) -> &MessageBuilder<Target>
Converts this type into a shared reference of the (usually inferred) input type.
sourceimpl<Target> AsRef<Target> for QuestionBuilder<Target>
impl<Target> AsRef<Target> for QuestionBuilder<Target>
sourceimpl<Target: Clone> Clone for QuestionBuilder<Target>
impl<Target: Clone> Clone for QuestionBuilder<Target>
sourcefn clone(&self) -> QuestionBuilder<Target>
fn clone(&self) -> QuestionBuilder<Target>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<Target: Debug> Debug for QuestionBuilder<Target>
impl<Target: Debug> Debug for QuestionBuilder<Target>
sourceimpl<Target> Deref for QuestionBuilder<Target>
impl<Target> Deref for QuestionBuilder<Target>
type Target = MessageBuilder<Target>
type Target = MessageBuilder<Target>
The resulting type after dereferencing.
sourceimpl<Target> DerefMut for QuestionBuilder<Target>
impl<Target> DerefMut for QuestionBuilder<Target>
sourceimpl<Target> From<AdditionalBuilder<Target>> for QuestionBuilder<Target>where
Target: OctetsBuilder + AsMut<[u8]>,
impl<Target> From<AdditionalBuilder<Target>> for QuestionBuilder<Target>where
Target: OctetsBuilder + AsMut<[u8]>,
sourcefn from(src: AdditionalBuilder<Target>) -> Self
fn from(src: AdditionalBuilder<Target>) -> Self
Converts to this type from the input type.
sourceimpl<Target> From<AnswerBuilder<Target>> for QuestionBuilder<Target>where
Target: OctetsBuilder + AsMut<[u8]>,
impl<Target> From<AnswerBuilder<Target>> for QuestionBuilder<Target>where
Target: OctetsBuilder + AsMut<[u8]>,
sourcefn from(src: AnswerBuilder<Target>) -> Self
fn from(src: AnswerBuilder<Target>) -> Self
Converts to this type from the input type.
sourceimpl<Target> From<AuthorityBuilder<Target>> for QuestionBuilder<Target>where
Target: OctetsBuilder + AsMut<[u8]>,
impl<Target> From<AuthorityBuilder<Target>> for QuestionBuilder<Target>where
Target: OctetsBuilder + AsMut<[u8]>,
sourcefn from(src: AuthorityBuilder<Target>) -> Self
fn from(src: AuthorityBuilder<Target>) -> Self
Converts to this type from the input type.
sourceimpl<Target> From<MessageBuilder<Target>> for QuestionBuilder<Target>where
Target: OctetsBuilder,
impl<Target> From<MessageBuilder<Target>> for QuestionBuilder<Target>where
Target: OctetsBuilder,
sourcefn from(src: MessageBuilder<Target>) -> Self
fn from(src: MessageBuilder<Target>) -> Self
Converts to this type from the input type.
sourceimpl<Target> From<QuestionBuilder<Target>> for AdditionalBuilder<Target>where
Target: OctetsBuilder,
impl<Target> From<QuestionBuilder<Target>> for AdditionalBuilder<Target>where
Target: OctetsBuilder,
sourcefn from(src: QuestionBuilder<Target>) -> Self
fn from(src: QuestionBuilder<Target>) -> Self
Converts to this type from the input type.
sourceimpl<Target> From<QuestionBuilder<Target>> for AnswerBuilder<Target>where
Target: OctetsBuilder,
impl<Target> From<QuestionBuilder<Target>> for AnswerBuilder<Target>where
Target: OctetsBuilder,
sourcefn from(src: QuestionBuilder<Target>) -> Self
fn from(src: QuestionBuilder<Target>) -> Self
Converts to this type from the input type.
sourceimpl<Target> From<QuestionBuilder<Target>> for AuthorityBuilder<Target>where
Target: OctetsBuilder,
impl<Target> From<QuestionBuilder<Target>> for AuthorityBuilder<Target>where
Target: OctetsBuilder,
sourcefn from(src: QuestionBuilder<Target>) -> Self
fn from(src: QuestionBuilder<Target>) -> Self
Converts to this type from the input type.
sourceimpl<Target> From<QuestionBuilder<Target>> for MessageBuilder<Target>where
Target: OctetsBuilder + AsMut<[u8]>,
impl<Target> From<QuestionBuilder<Target>> for MessageBuilder<Target>where
Target: OctetsBuilder + AsMut<[u8]>,
sourcefn from(src: QuestionBuilder<Target>) -> Self
fn from(src: QuestionBuilder<Target>) -> Self
Converts to this type from the input type.
Auto Trait Implementations
impl<Target> RefUnwindSafe for QuestionBuilder<Target>where
Target: RefUnwindSafe,
impl<Target> Send for QuestionBuilder<Target>where
Target: Send,
impl<Target> Sync for QuestionBuilder<Target>where
Target: Sync,
impl<Target> Unpin for QuestionBuilder<Target>where
Target: Unpin,
impl<Target> UnwindSafe for QuestionBuilder<Target>where
Target: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Source, Target> OctetsInto<Target> for Sourcewhere
Target: OctetsFrom<Source>,
impl<Source, Target> OctetsInto<Target> for Sourcewhere
Target: OctetsFrom<Source>,
sourcefn octets_into(self) -> Result<Target, ShortBuf>
fn octets_into(self) -> Result<Target, ShortBuf>
Performs the conversion.