Struct domain::base::message_builder::MessageBuilder
source · pub struct MessageBuilder<Target> { /* private fields */ }
Expand description
Starts building a DNS message.
This type wraps an OctetsBuilder
and starts the process of building a
message. It allows access to the header section. The message builder can
be traded in for any section builder or the underlying octets builder.
For more details see the module documentation.
Implementations§
source§impl<Target: OctetsBuilder + Truncate> MessageBuilder<Target>
impl<Target: OctetsBuilder + Truncate> MessageBuilder<Target>
§Creating Message Builders
sourcepub fn from_target(target: Target) -> Result<Self, Target::AppendError>
pub fn from_target(target: Target) -> Result<Self, Target::AppendError>
Creates a new message builder using the given target.
The target must be an OctetsBuilder
. It will be truncated to zero
size before appending the header section. That is, all data that was
in the builder before will be lost.
The function will result in an error if the builder doesn’t have enough space for the header section.
source§impl MessageBuilder<Vec<u8>>
impl MessageBuilder<Vec<u8>>
source§impl MessageBuilder<StreamTarget<Vec<u8>>>
impl MessageBuilder<StreamTarget<Vec<u8>>>
sourcepub fn new_stream_vec() -> Self
pub fn new_stream_vec() -> Self
Creates a new builder for a streamable message atop a Vec<u8>
.
source§impl MessageBuilder<StreamTarget<BytesMut>>
impl MessageBuilder<StreamTarget<BytesMut>>
sourcepub fn new_stream_bytes() -> Self
pub fn new_stream_bytes() -> Self
Creates a new streamable message builder atop a bytes value.
source§impl<Target: Composer> MessageBuilder<Target>
impl<Target: Composer> MessageBuilder<Target>
sourcepub fn start_answer<Octs: Octets + ?Sized>(
self,
msg: &Message<Octs>,
rcode: Rcode,
) -> Result<AnswerBuilder<Target>, PushError>
pub fn start_answer<Octs: Octets + ?Sized>( self, msg: &Message<Octs>, rcode: Rcode, ) -> Result<AnswerBuilder<Target>, PushError>
Starts creating an answer for the given message.
Specifically, this sets the ID, QR, OPCODE, RD, and RCODE fields in the header and attempts to push the message’s questions to the builder. If iterating of the questions fails, it adds what it can.
The method converts the message builder into an answer builder ready to receive the answer for the question.
sourcepub fn request_axfr<N: ToDname>(
self,
apex: N,
) -> Result<AnswerBuilder<Target>, PushError>
pub fn request_axfr<N: ToDname>( self, apex: N, ) -> Result<AnswerBuilder<Target>, PushError>
Creates an AXFR request for the given domain.
Sets a random ID, pushes the domain and the AXFR record type into the question section, and converts the builder into an answer builder.
source§impl<Target: OctetsBuilder + AsRef<[u8]>> MessageBuilder<Target>
impl<Target: OctetsBuilder + AsRef<[u8]>> MessageBuilder<Target>
§Access to the Message Header
source§impl<Target: OctetsBuilder + AsMut<[u8]>> MessageBuilder<Target>
impl<Target: OctetsBuilder + AsMut<[u8]>> MessageBuilder<Target>
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.
source§impl<Target: Composer> MessageBuilder<Target>
impl<Target: Composer> MessageBuilder<Target>
§Conversions
sourcepub fn builder(self) -> MessageBuilder<Target>
pub fn builder(self) -> MessageBuilder<Target>
Converts the message builder into a message builder
This is a no-op.
sourcepub fn question(self) -> QuestionBuilder<Target>
pub fn question(self) -> QuestionBuilder<Target>
Converts the message builder into a question builder.
sourcepub fn answer(self) -> AnswerBuilder<Target>
pub fn answer(self) -> AnswerBuilder<Target>
Converts the message builder into an answer builder.
This will leave the question section empty.
Converts the message builder into an authority builder.
This will leave the question and answer sections empty.
sourcepub fn additional(self) -> AdditionalBuilder<Target>
pub fn additional(self) -> AdditionalBuilder<Target>
Converts the message builder into an additional builder.
This will leave the question, answer, and authority sections empty.
sourcepub fn finish(self) -> Target
pub fn finish(self) -> Target
Converts the message into the underlying octets builder.
This will leave the all sections empty.
sourcepub fn into_message(self) -> Message<<Target as FreezeBuilder>::Octets>where
Target: FreezeBuilder,
pub fn into_message(self) -> Message<<Target as FreezeBuilder>::Octets>where
Target: FreezeBuilder,
Converts the builder into a message.
The method will return a message atop whatever octets sequence the builder’s octets builder converts into.
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> 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> AsMut<MessageBuilder<Target>> for AuthorityBuilder<Target>
impl<Target> AsMut<MessageBuilder<Target>> for AuthorityBuilder<Target>
source§fn as_mut(&mut self) -> &mut MessageBuilder<Target>
fn as_mut(&mut self) -> &mut MessageBuilder<Target>
source§impl<Target> AsMut<MessageBuilder<Target>> for QuestionBuilder<Target>
impl<Target> AsMut<MessageBuilder<Target>> for QuestionBuilder<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<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<MessageBuilder<Target>> for AuthorityBuilder<Target>
impl<Target> AsRef<MessageBuilder<Target>> for AuthorityBuilder<Target>
source§fn as_ref(&self) -> &MessageBuilder<Target>
fn as_ref(&self) -> &MessageBuilder<Target>
source§impl<Target> AsRef<MessageBuilder<Target>> for QuestionBuilder<Target>
impl<Target> AsRef<MessageBuilder<Target>> for QuestionBuilder<Target>
source§fn as_ref(&self) -> &MessageBuilder<Target>
fn as_ref(&self) -> &MessageBuilder<Target>
source§impl<Target> AsRef<Target> for MessageBuilder<Target>
impl<Target> AsRef<Target> for MessageBuilder<Target>
source§impl<Target: Clone> Clone for MessageBuilder<Target>
impl<Target: Clone> Clone for MessageBuilder<Target>
source§fn clone(&self) -> MessageBuilder<Target>
fn clone(&self) -> MessageBuilder<Target>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more