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.
The method converts the message builder into an answer builder ready to receive the answer for the question.
sourcepub fn start_error<Octs: Octets + ?Sized>(
self,
msg: &Message<Octs>,
rcode: Rcode,
) -> AnswerBuilder<Target>
pub fn start_error<Octs: Octets + ?Sized>( self, msg: &Message<Octs>, rcode: Rcode, ) -> AnswerBuilder<Target>
Starts creating an error for the given message.
Like start_answer()
but infallible. Questions
will be pushed if possible.
sourcepub fn request_axfr<N: ToName>(
self,
apex: N,
) -> Result<AnswerBuilder<Target>, PushError>
pub fn request_axfr<N: ToName>( 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: Composer> MessageBuilder<Target>
impl<Target: Composer> MessageBuilder<Target>
§Limiting message size
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.
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> MessageBuilder<Target>
impl<Target> 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.
source§impl<Target: Composer> MessageBuilder<Target>
impl<Target: Composer> MessageBuilder<Target>
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.
source§impl<Target: FreezeBuilder> MessageBuilder<Target>
impl<Target: FreezeBuilder> MessageBuilder<Target>
sourcepub fn into_message(self) -> Message<Target::Octets>
pub fn into_message(self) -> Message<Target::Octets>
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 moresource§impl<Target: Debug> Debug for MessageBuilder<Target>
impl<Target: Debug> Debug for MessageBuilder<Target>
source§impl<Target> From<AdditionalBuilder<Target>> for MessageBuilder<Target>where
Target: Composer,
impl<Target> From<AdditionalBuilder<Target>> for MessageBuilder<Target>where
Target: Composer,
source§fn from(src: AdditionalBuilder<Target>) -> Self
fn from(src: AdditionalBuilder<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<AuthorityBuilder<Target>> for MessageBuilder<Target>where
Target: Composer,
impl<Target> From<AuthorityBuilder<Target>> for MessageBuilder<Target>where
Target: Composer,
source§fn from(src: AuthorityBuilder<Target>) -> Self
fn from(src: AuthorityBuilder<Target>) -> Self
source§impl<Target> From<MessageBuilder<Target>> for AdditionalBuilder<Target>where
Target: Composer,
impl<Target> From<MessageBuilder<Target>> for AdditionalBuilder<Target>where
Target: Composer,
source§fn from(src: MessageBuilder<Target>) -> Self
fn from(src: MessageBuilder<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<MessageBuilder<Target>> for AuthorityBuilder<Target>where
Target: Composer,
impl<Target> From<MessageBuilder<Target>> for AuthorityBuilder<Target>where
Target: Composer,
source§fn from(src: MessageBuilder<Target>) -> Self
fn from(src: MessageBuilder<Target>) -> Self
source§impl<Target> From<MessageBuilder<Target>> for Message<Target::Octets>where
Target: FreezeBuilder,
impl<Target> From<MessageBuilder<Target>> for Message<Target::Octets>where
Target: FreezeBuilder,
source§fn from(src: MessageBuilder<Target>) -> Self
fn from(src: MessageBuilder<Target>) -> Self
source§impl<Target> From<MessageBuilder<Target>> for QuestionBuilder<Target>where
Target: Composer,
impl<Target> From<MessageBuilder<Target>> for QuestionBuilder<Target>where
Target: Composer,
source§fn from(src: MessageBuilder<Target>) -> Self
fn from(src: MessageBuilder<Target>) -> Self
source§impl<Target> From<QuestionBuilder<Target>> for MessageBuilder<Target>where
Target: Composer,
impl<Target> From<QuestionBuilder<Target>> for MessageBuilder<Target>where
Target: Composer,
source§fn from(src: QuestionBuilder<Target>) -> Self
fn from(src: QuestionBuilder<Target>) -> Self
Auto Trait Implementations§
impl<Target> Freeze for MessageBuilder<Target>where
Target: Freeze,
impl<Target> RefUnwindSafe for MessageBuilder<Target>where
Target: RefUnwindSafe,
impl<Target> Send for MessageBuilder<Target>where
Target: Send,
impl<Target> Sync for MessageBuilder<Target>where
Target: Sync,
impl<Target> Unpin for MessageBuilder<Target>where
Target: Unpin,
impl<Target> UnwindSafe for MessageBuilder<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
)