Struct domain::bits::message_builder::MessageBuilder
[−]
[src]
pub struct MessageBuilder { /* fields omitted */ }
A type for building the question section of a DNS message.
This type starts building a DNS message and allows adding questions to its question section. See the module documentation for details.
Methods
impl MessageBuilder
[src]
fn new(mode: ComposeMode, compress: bool) -> ComposeResult<Self>
Creates a new empty DNS message.
The mode
argument decides whether the message will have a size
limit and whether it should include the length prefix for use with
stream transports. If compress
is true
, name compression will
be enabled for the message.
This function may fail if the size limit in mode
is too small to
even add the header section.
fn from_vec(
vec: Vec<u8>,
mode: ComposeMode,
compress: bool
) -> ComposeResult<Self>
vec: Vec<u8>,
mode: ComposeMode,
compress: bool
) -> ComposeResult<Self>
Creates a new DNS message appended to the content of a bytes vector.
The mode
argument decides whether the message will have a size
limit and whether it should include the length prefix for use with
stream transports. If compress
is true
, name compression will
be enabled for the message.
This function may fail if the size limit in mode
is too small to
even add the header section.
fn from_composer(composer: Composer) -> ComposeResult<Self>
Creates a new DNS message atop an existing composer.
This doesn’t reset the composer but starts off after whatever is in there already. As this may result in invalid message, user discretion is advised.
impl MessageBuilder
[src]
fn header(&self) -> &Header
Returns a reference to the message’s header.
fn header_mut(&mut self) -> &mut Header
Returns a mutable reference to the message’s header.
fn push<N: DName, Q: Into<Question<N>>>(
&mut self,
question: Q
) -> ComposeResult<()>
&mut self,
question: Q
) -> ComposeResult<()>
Appends a new question to the message.
This function is generic over anything that can be converted into a
Question
. In particular, triples of a domain name, a record type,
and a class as well as pairs of just a domain name and a record type
fulfill this requirement with the class assumed to be Class::In
in
the latter case.
fn rewind(&mut self)
Rewinds to the beginning of the question section.
This drops all previously assembled questions.
fn answer(self) -> AnswerBuilder
Proceeds to building the answer section.
Proceeds to building the authority section, skipping the answer.
fn additional(self) -> AdditionalBuilder
Proceeds to building the additonal section.
Leaves the answer and additional sections empty.
fn preview(&mut self) -> &[u8]
Returns a reference to the message assembled so far.
This method requires a &mut self
since it may need to update some
length values to return a valid message.
In case the builder was created from a vector with previous content, the returned reference is for the full content of this vector.
fn finish(self) -> Vec<u8>
Finishes the message and returns the underlying target.
This will result in a message with all three record sections empty.
Trait Implementations
impl Clone for MessageBuilder
[src]
fn clone(&self) -> MessageBuilder
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more