MessageDecoder

Struct MessageDecoder 

Source
pub struct MessageDecoder<'a, S>
where S: Section,
{ /* private fields */ }
Expand description

Streaming decoder for DNS messages.

In DNS messages, sections are ordered as follows:

  • Question section
  • Answer section
  • Authority section
  • Additional Records section

To ensure efficient decoding and prevent misuse, the message decoder stores the section it is currently decoding as the S type parameter. Initially (after calling MessageDecoder::new), the decoder is in the section::Question state, and is advanced by calling the appropriate methods.

Implementations§

Source§

impl<'a> MessageDecoder<'a, Question>

Source

pub fn new(buf: &'a [u8]) -> Result<MessageDecoder<'a, Question>, Error>

Creates a streaming message decoder that will read from buf.

Source§

impl<'a, S> MessageDecoder<'a, S>
where S: Section,

Source

pub fn header(&self) -> &Header

Returns the message header.

Source§

impl<'a> MessageDecoder<'a, Question>

Source

pub fn next(&mut self) -> Option<Result<Question, Error>>

Reads the next Question from the Question section.

Source

pub fn iter(&mut self) -> QuestionIter<'_, 'a>

Returns an iterator over all Questions in the Question section of the message.

Source

pub fn answers(self) -> Result<MessageDecoder<'a, Answer>, Error>

Skips the remaining entries in the Question section and advances the decoder to the Answer section.

Source

pub fn authority(self) -> Result<MessageDecoder<'a, Authority>, Error>

Skips the remaining entries in the Question section, as well as all entries in the Answer section, and advances the decoder to the Authority section.

Source

pub fn additional(self) -> Result<MessageDecoder<'a, Additional>, Error>

Skips the remaining entries in the Question section, as well as all entries in the Answer and Authority sections, and advances the decoder to the Additional Records section.

Source§

impl<'a> MessageDecoder<'a, Answer>

Source

pub fn next(&mut self) -> Option<Result<ResourceRecord<'_>, Error>>

Reads the next ResourceRecord from the Answer section.

Source

pub fn iter(&mut self) -> ResourceRecordIter<'_, 'a, Answer>

Returns an iterator over all resource records in the Answer section.

Source

pub fn authority(self) -> Result<MessageDecoder<'a, Authority>, Error>

Skips the remaining entries in the Answer section, and advances the decoder to the Additional Records section.

Source

pub fn additional(self) -> Result<MessageDecoder<'a, Additional>, Error>

Skips the remaining entries in the Answer section, as well as all entries in the Authority section, and advances the decoder to the Additional Records section.

Source§

impl<'a> MessageDecoder<'a, Authority>

Source

pub fn next(&mut self) -> Option<Result<ResourceRecord<'_>, Error>>

Reads the next ResourceRecord from the Authority section.

Source

pub fn iter(&mut self) -> ResourceRecordIter<'_, 'a, Authority>

Returns an iterator over all resource records in the Authority section.

Source

pub fn additional(self) -> Result<MessageDecoder<'a, Additional>, Error>

Source§

impl<'a> MessageDecoder<'a, Additional>

Source

pub fn next(&mut self) -> Option<Result<ResourceRecord<'_>, Error>>

Reads the next ResourceRecord from the Additional Records section.

Source

pub fn iter(&mut self) -> ResourceRecordIter<'_, 'a, Additional>

Returns an iterator over all resource records in the Additional Record section.

Auto Trait Implementations§

§

impl<'a, S> !Freeze for MessageDecoder<'a, S>

§

impl<'a, S> !RefUnwindSafe for MessageDecoder<'a, S>

§

impl<'a, S> !Send for MessageDecoder<'a, S>

§

impl<'a, S> !Sync for MessageDecoder<'a, S>

§

impl<'a, S> Unpin for MessageDecoder<'a, S>
where S: Unpin,

§

impl<'a, S> UnwindSafe for MessageDecoder<'a, S>
where S: UnwindSafe,

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<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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<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