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]
impl MessageBuilder
pub fn new(mode: ComposeMode, compress: bool) -> ComposeResult<Self>
[src]
pub 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.
pub fn from_vec(
vec: Vec<u8>,
mode: ComposeMode,
compress: bool
) -> ComposeResult<Self>
[src]
pub fn from_vec(
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.
pub fn from_composer(composer: Composer) -> ComposeResult<Self>
[src]
pub 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]
impl MessageBuilder
pub fn header(&self) -> &Header
[src]
pub fn header(&self) -> &Header
Returns a reference to the message’s header.
pub fn header_mut(&mut self) -> &mut Header
[src]
pub fn header_mut(&mut self) -> &mut Header
Returns a mutable reference to the message’s header.
pub fn push<N: DName, Q: Into<Question<N>>>(
&mut self,
question: Q
) -> ComposeResult<()>
[src]
pub fn push<N: DName, Q: Into<Question<N>>>(
&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.
pub fn rewind(&mut self)
[src]
pub fn rewind(&mut self)
Rewinds to the beginning of the question section.
This drops all previously assembled questions.
pub fn answer(self) -> AnswerBuilder
[src]
pub fn answer(self) -> AnswerBuilder
Proceeds to building the answer section.
Proceeds to building the authority section, skipping the answer.
pub fn additional(self) -> AdditionalBuilder
[src]
pub fn additional(self) -> AdditionalBuilder
Proceeds to building the additonal section.
Leaves the answer and additional sections empty.
pub fn preview(&mut self) -> &[u8]
[src]
pub 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.
pub fn finish(self) -> Vec<u8>
[src]
pub 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]
impl Clone for MessageBuilder
fn clone(&self) -> MessageBuilder
[src]
fn clone(&self) -> MessageBuilder
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Debug for MessageBuilder
[src]
impl Debug for MessageBuilder
Auto Trait Implementations
impl Send for MessageBuilder
impl Send for MessageBuilder
impl Sync for MessageBuilder
impl Sync for MessageBuilder