Struct domain::resolv::stub::Answer

source ·
pub struct Answer { /* private fields */ }
Available on crate feature 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§

source§

impl Answer

source

pub fn is_final(&self) -> bool

Returns whether the answer is a final answer to be returned.

source

pub fn is_truncated(&self) -> bool

Returns whether the answer is truncated.

source

pub fn into_message(self) -> Message<Bytes>

Methods from Deref<Target = Message<Bytes>>§

source

pub fn as_octets(&self) -> &Octs

Returns a reference to the underlying octets sequence.

source

pub fn as_slice(&self) -> &[u8]
where Octs: AsRef<[u8]>,

Returns a slice to the underlying octets sequence.

source

pub fn for_slice(&self) -> &Message<[u8]>
where Octs: AsRef<[u8]>,

Returns a message for a slice of the octets sequence.

source

pub fn for_slice_ref(&self) -> Message<&[u8]>
where Octs: AsRef<[u8]>,

Returns a message for a slice reference.

source

pub fn header(&self) -> Header

Returns the message header.

source

pub fn header_counts(&self) -> HeaderCounts

Returns the header counts of the message.

source

pub fn header_section(&self) -> HeaderSection

Returns the entire header section.

source

pub fn no_error(&self) -> bool

Returns whether the rcode of the header is NoError.

source

pub fn is_error(&self) -> bool

Returns whether the rcode of the header is one of the error values.

source

pub fn question(&self) -> QuestionSection<'_, Octs>

Returns the question section.

source

pub fn zone(&self) -> QuestionSection<'_, Octs>

Returns the zone section of an UPDATE message.

This is identical to self.question().

source

pub fn answer(&self) -> Result<RecordSection<'_, Octs>, 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.

source

pub fn prerequisite(&self) -> Result<RecordSection<'_, Octs>, ParseError>

Returns the prerequisite section of an UPDATE message.

This is identical to self.answer().

source

pub fn authority(&self) -> Result<RecordSection<'_, Octs>, ParseError>

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.

source

pub fn update(&self) -> Result<RecordSection<'_, Octs>, ParseError>

Returns the update section of an UPDATE message.

This is identical to self.authority().

source

pub fn additional(&self) -> Result<RecordSection<'_, Octs>, 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.

source

pub fn sections( &self ) -> Result<(QuestionSection<'_, Octs>, RecordSection<'_, Octs>, RecordSection<'_, Octs>, RecordSection<'_, Octs>), ParseError>

Returns all four sections in one fell swoop.

source

pub fn iter(&self) -> MessageIter<'_, Octs>

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.

source

pub fn is_answer<Other: Octets>(&self, query: &Message<Other>) -> bool

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.

source

pub fn first_question(&self) -> Option<Question<ParsedName<Octs::Range<'_>>>>

Returns the first question, if there is any.

The method will return None both if there are no questions or if parsing fails.

source

pub fn sole_question( &self ) -> Result<Question<ParsedName<Octs::Range<'_>>>, 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.

source

pub fn qtype(&self) -> Option<Rtype>

Returns the query type of the first question, if any.

source

pub fn contains_answer<'s, Data>(&'s self) -> bool
where Data: ParseRecordData<'s, Octs>,

Returns whether the message contains answers of a given type.

source

pub fn canonical_name(&self) -> Option<ParsedName<Octs::Range<'_>>>

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.

source

pub fn opt(&self) -> Option<OptRecord<Octs::Range<'_>>>

Returns the OPT record from the message, if there is one.

source

pub fn get_last_additional<'s, Data: ParseRecordData<'s, Octs>>( &'s self ) -> Option<Record<ParsedName<Octs::Range<'s>>, 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.

source

pub fn copy_records<'s, R, F, T, O>( &'s self, target: T, op: F ) -> Result<AdditionalBuilder<O>, CopyRecordsError>
where Octs: Octets, R: ComposeRecord + 's, F: FnMut(ParsedRecord<'s, Octs>) -> Option<R>, T: Into<AnswerBuilder<O>>, O: Composer,

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.

source

pub fn opt_rcode(&self) -> OptRcode

Get the extended rcode of a message or the normal rcode converted to an extended rcode if no opt record is present.

Trait Implementations§

source§

impl AsRef<Message<Bytes>> for Answer

source§

fn as_ref(&self) -> &Message<Bytes>

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Clone for Answer

source§

fn clone(&self) -> Answer

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Deref for Answer

§

type Target = Message<Bytes>

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl From<Message<Bytes>> for Answer

source§

fn from(message: Message<Bytes>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl !Freeze for Answer

§

impl RefUnwindSafe for Answer

§

impl Send for Answer

§

impl Sync for Answer

§

impl Unpin for Answer

§

impl UnwindSafe for Answer

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<Source, Target> OctetsInto<Target> for Source
where Target: OctetsFrom<Source>,

§

type Error = <Target as OctetsFrom<Source>>::Error

source§

fn try_octets_into( self ) -> Result<Target, <Source as OctetsInto<Target>>::Error>

Performs the conversion.
source§

fn octets_into(self) -> Target
where Self::Error: Into<Infallible>,

Performs an infallible conversion.
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more