pub struct QueryBuilder { /* private fields */ }
Expand description
Builds a query DNS message.
You can create a new query from a given question using the new
function. The add_opt
method provides the means to add an OPT record
to the additional section. The entire additional section can later be
removed through the revert_additional
function.
Once you are happy with your query, you can turn it into a
QueryMessage
through the freeze
method.
Implementations§
Source§impl QueryBuilder
impl QueryBuilder
Sourcepub fn new<N: ToDname, Q: Into<Question<N>>>(question: Q) -> Self
pub fn new<N: ToDname, Q: Into<Question<N>>>(question: Q) -> Self
Creates a new query builder.
The query will contain one question built from question
. It will
have a random ID. The RD bit will not be set. If you desire
recursion, you can enable it via the set_rd
method.
Sourcepub fn header_mut(&mut self) -> &mut Header
pub fn header_mut(&mut self) -> &mut Header
Returns a mutable reference to the header of the query.
Sourcepub fn set_rd(&mut self, value: bool)
pub fn set_rd(&mut self, value: bool)
Sets the ‘recursion desired’ (RD) bit to the given value.
This is a shortcut to self.header_mut().set_rd(value)
.
By default, this bit is not set.
Sourcepub fn add_opt<F>(&mut self, op: F)where
F: FnOnce(&mut OptBuilder<'_>),
pub fn add_opt<F>(&mut self, op: F)where
F: FnOnce(&mut OptBuilder<'_>),
Adds an OPT record to the additional section.
The content of the record can be manipulated in the closure provided
as an argument. This closure receives a mutable reference to an
OptBuilder
which will allow access to the OPT record’s header as
well as allow adding options.
Sourcepub fn revert_additional(&mut self)
pub fn revert_additional(&mut self)
Removes all records from the additional section.
Afterwards, only the single question will remain in the message.
Sourcepub fn freeze(self) -> QueryMessage
pub fn freeze(self) -> QueryMessage
Freezes the query builder into a query message.
Trait Implementations§
Source§impl Clone for QueryBuilder
impl Clone for QueryBuilder
Source§fn clone(&self) -> QueryBuilder
fn clone(&self) -> QueryBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more