pub struct Answer { /* private fields */ }
resolv
only.Expand description
The answer to a question.
This type is a wrapper around the DNS Message
containing the answer
that provides some additional information.
Implementations
Methods from Deref<Target = Message<Bytes>>
sourcepub fn header_counts(&self) -> HeaderCounts
pub fn header_counts(&self) -> HeaderCounts
Returns the header counts of the message.
sourcepub fn header_section(&self) -> HeaderSection
pub fn header_section(&self) -> HeaderSection
Returns the entire header section.
sourcepub fn question(&self) -> QuestionSection<&Octets>ⓘNotable traits for QuestionSection<Ref>impl<Ref: OctetsRef> Iterator for QuestionSection<Ref> type Item = Result<Question<ParsedDname<Ref>>, ParseError>;
pub fn question(&self) -> QuestionSection<&Octets>ⓘNotable traits for QuestionSection<Ref>impl<Ref: OctetsRef> Iterator for QuestionSection<Ref> type Item = Result<Question<ParsedDname<Ref>>, ParseError>;
Returns the question section.
sourcepub fn zone(&self) -> QuestionSection<&Octets>ⓘNotable traits for QuestionSection<Ref>impl<Ref: OctetsRef> Iterator for QuestionSection<Ref> type Item = Result<Question<ParsedDname<Ref>>, ParseError>;
pub fn zone(&self) -> QuestionSection<&Octets>ⓘNotable traits for QuestionSection<Ref>impl<Ref: OctetsRef> Iterator for QuestionSection<Ref> type Item = Result<Question<ParsedDname<Ref>>, ParseError>;
Returns the zone section of an UPDATE message.
This is identical to self.question()
.
sourcepub fn answer(&self) -> Result<RecordSection<&Octets>, ParseError>
pub fn answer(&self) -> Result<RecordSection<&Octets>, ParseError>
Returns the answer section.
Iterates over the question section in order to access the answer
section. If you are accessing the question section anyway, using
its next_section
method may be more efficient.
sourcepub fn prerequisite(&self) -> Result<RecordSection<&Octets>, ParseError>
pub fn prerequisite(&self) -> Result<RecordSection<&Octets>, ParseError>
Returns the prerequisite section of an UPDATE message.
This is identical to self.answer()
.
Returns the authority section.
Iterates over both the question and the answer sections to determine
the start of the authority section. If you are already accessing the
answer section, using next_section
on it is more efficient.
sourcepub fn update(&self) -> Result<RecordSection<&Octets>, ParseError>
pub fn update(&self) -> Result<RecordSection<&Octets>, ParseError>
Returns the update section of an UPDATE message.
This is identical to self.authority()
.
sourcepub fn additional(&self) -> Result<RecordSection<&Octets>, ParseError>
pub fn additional(&self) -> Result<RecordSection<&Octets>, ParseError>
Returns the additional section.
Iterates over all three previous sections to determine the start of
the additional section. If you are already accessing the
authority section, using next_section
on it is more efficient.
sourcepub fn sections(
&self
) -> Result<(QuestionSection<&Octets>, RecordSection<&Octets>, RecordSection<&Octets>, RecordSection<&Octets>), ParseError>
pub fn sections(
&self
) -> Result<(QuestionSection<&Octets>, RecordSection<&Octets>, RecordSection<&Octets>, RecordSection<&Octets>), ParseError>
Returns all four sections in one fell swoop.
sourcepub fn iter(&self) -> MessageIter<&Octets>ⓘNotable traits for MessageIter<Ref>impl<Ref: OctetsRef> Iterator for MessageIter<Ref> type Item = Result<(ParsedRecord<Ref>, Section), ParseError>;
pub fn iter(&self) -> MessageIter<&Octets>ⓘNotable traits for MessageIter<Ref>impl<Ref: OctetsRef> Iterator for MessageIter<Ref> type Item = Result<(ParsedRecord<Ref>, Section), ParseError>;
Returns an iterator over the records in the message.
The iterator’s item is a pair of a ParsedRecord
and the
Section
it was found in.
As is customary, this iterator is also accessible via the
IntoIterator
trait on a reference to the message.
sourcepub fn is_answer<Other>(&self, query: &Message<Other>) -> boolwhere
Other: AsRef<[u8]>,
for<'o> &'o Other: OctetsRef,
pub fn is_answer<Other>(&self, query: &Message<Other>) -> boolwhere
Other: AsRef<[u8]>,
for<'o> &'o Other: OctetsRef,
Returns whether this is the answer to some other message.
The method checks whether the ID fields of the headers are the same, whether the QR flag is set in this message, and whether the questions are the same.
sourcepub fn first_question(&self) -> Option<Question<ParsedDname<&Octets>>>
pub fn first_question(&self) -> Option<Question<ParsedDname<&Octets>>>
Returns the first question, if there is any.
The method will return None
both if there are no questions or if
parsing fails.
sourcepub fn sole_question(
&self
) -> Result<Question<ParsedDname<&Octets>>, ParseError>
pub fn sole_question(
&self
) -> Result<Question<ParsedDname<&Octets>>, ParseError>
Returns the sole question of the message.
This is like first_question
but returns an error if there isn’t
exactly one question or there is a parse error.
sourcepub fn contains_answer<'s, Data>(&'s self) -> boolwhere
Data: ParseRecordData<&'s Octets>,
pub fn contains_answer<'s, Data>(&'s self) -> boolwhere
Data: ParseRecordData<&'s Octets>,
Returns whether the message contains answers of a given type.
sourcepub fn canonical_name(&self) -> Option<ParsedDname<&Octets>>
pub fn canonical_name(&self) -> Option<ParsedDname<&Octets>>
Resolves the canonical name of the answer.
The CNAME record allows a domain name to be an alias for a different name. Aliases may be chained. The ‘canonical name’ referred to be the method’s name is the last name in this chain. A recursive resolver will support a stub resolver in figuring out this canonical name by including all necessary CNAME records in its answer. This method can be used on such an answer to determine the canonical name. As such, it will only consider CNAMEs present in the message’s answer section.
It starts with the question name and follows CNAME records until there is no next CNAME in the chain and then returns the last CNAME.
If the message doesn’t have a question, if there is a parse error, or
if there is a CNAME loop the method returns None
.
sourcepub fn opt(&self) -> Option<OptRecord<<&Octets as OctetsRef>::Range>>
pub fn opt(&self) -> Option<OptRecord<<&Octets as OctetsRef>::Range>>
Returns the OPT record from the message, if there is one.
sourcepub fn get_last_additional<'s, Data: ParseRecordData<&'s Octets>>(
&'s self
) -> Option<Record<ParsedDname<&'s Octets>, Data>>
pub fn get_last_additional<'s, Data: ParseRecordData<&'s Octets>>(
&'s self
) -> Option<Record<ParsedDname<&'s Octets>, Data>>
Returns the last additional record from the message.
The method tries to parse the last record of the additional section as the provided record type. If that succeeds, it returns that parsed record.
If the last record is of the wrong type or parsing fails, returns
None
.
sourcepub fn copy_records<'s, R, F, T, O>(
&'s self,
target: T,
op: F
) -> Result<AdditionalBuilder<O>, CopyRecordsError>where
for<'a> &'a Octets: OctetsRef,
R: AsRecord + 's,
F: FnMut(ParsedRecord<&'s Octets>) -> Option<R>,
T: Into<AnswerBuilder<O>>,
O: OctetsBuilder + AsMut<[u8]>,
pub fn copy_records<'s, R, F, T, O>(
&'s self,
target: T,
op: F
) -> Result<AdditionalBuilder<O>, CopyRecordsError>where
for<'a> &'a Octets: OctetsRef,
R: AsRecord + 's,
F: FnMut(ParsedRecord<&'s Octets>) -> Option<R>,
T: Into<AnswerBuilder<O>>,
O: OctetsBuilder + AsMut<[u8]>,
Copy records from a message into the target message builder.
The method uses op
to process records from all record sections
before inserting, caller can use this closure to filter or manipulate
records before inserting.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Answer
impl Send for Answer
impl Sync for Answer
impl Unpin for Answer
impl UnwindSafe for Answer
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Source, Target> OctetsInto<Target> for Sourcewhere
Target: OctetsFrom<Source>,
impl<Source, Target> OctetsInto<Target> for Sourcewhere
Target: OctetsFrom<Source>,
sourcefn octets_into(self) -> Result<Target, ShortBuf>
fn octets_into(self) -> Result<Target, ShortBuf>
Performs the conversion.