WireEncoder

Struct WireEncoder 

Source
pub struct WireEncoder<'a, Q: QueryOrResponse, S: EncoderState> { /* private fields */ }
Expand description

Writes a DNS message to an external buffer.

WireEncoder guards against buffer overflow. If the external buffer is too small to contain all content, then the encoder sets the message’s TC (truncation) flag and elides questions and/or resource records such that the DNS message is valid and fits within the buffer.

Implementations§

Source§

impl<'a, Q: QueryOrResponse> WireEncoder<'a, Q, QuestionSection>

Source

pub fn finalize_questions(self) -> WireEncoder<'a, Q, AnswerSection>

Transitions the encoder into a state for encoding answers.

Source

pub fn encode_question<'b, F: Format<'b>>( &mut self, q: &'b Question<'b, F>, ) -> Result<(), EncoderError>

Source§

impl<'a> WireEncoder<'a, Query, QuestionSection>

Source

pub fn new_query(buffer: &'a mut [u8], id: u16) -> Result<Self, EncoderError>

Source§

impl<'a> WireEncoder<'a, Response, AnswerSection>

Source

pub fn new_response( buffer: &'a mut [u8], request: &WireMessage<'_>, ) -> Result<Self, EncoderError>

Constructs an encoder for encoding a response message.

The target response is initialized such that:

  • Its ID field is copied from the request.
  • Its QR bit is set.
  • Its RD bit is copied from the request.
  • Its question section is copied verbatim from the request.

If the request contains multiple questions, then the response will also contain multiple questions.

Source

pub fn finalize_answers(self) -> WireEncoder<'a, Response, AuthoritySection>

Source

pub fn encode_answer<'b, F: Format<'b>>( &mut self, r: &'b ResourceRecord<'b, F>, ) -> Result<(), EncoderError>

Source§

impl<'a> WireEncoder<'a, Response, AuthoritySection>

Source

pub fn finalize_authorities( self, ) -> WireEncoder<'a, Response, AdditionalSection>

Source

pub fn encode_authority<'b, F: Format<'b>>( &mut self, r: &'b ResourceRecord<'b, F>, ) -> Result<(), EncoderError>

Source§

impl<'a> WireEncoder<'a, Response, AdditionalSection>

Source

pub fn finalize_additionals(self) -> WireEncoder<'a, Response, Done>

Source

pub fn encode_additional<'b, F: Format<'b>>( &mut self, r: &'b ResourceRecord<'b, F>, ) -> Result<(), EncoderError>

Source§

impl<'a, Q: QueryOrResponse> WireEncoder<'a, Q, Done>

Source

pub fn as_bytes(&self) -> &[u8]

Trait Implementations§

Source§

impl<'a, Q: Debug + QueryOrResponse, S: Debug + EncoderState> Debug for WireEncoder<'a, Q, S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a, Q: PartialEq + QueryOrResponse, S: PartialEq + EncoderState> PartialEq for WireEncoder<'a, Q, S>

Source§

fn eq(&self, other: &WireEncoder<'a, Q, S>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, Q: Eq + QueryOrResponse, S: Eq + EncoderState> Eq for WireEncoder<'a, Q, S>

Source§

impl<'a, Q: QueryOrResponse, S: EncoderState> StructuralPartialEq for WireEncoder<'a, Q, S>

Auto Trait Implementations§

§

impl<'a, Q, S> Freeze for WireEncoder<'a, Q, S>

§

impl<'a, Q, S> RefUnwindSafe for WireEncoder<'a, Q, S>

§

impl<'a, Q, S> Send for WireEncoder<'a, Q, S>
where Q: Send, S: Send,

§

impl<'a, Q, S> Sync for WireEncoder<'a, Q, S>
where Q: Sync, S: Sync,

§

impl<'a, Q, S> Unpin for WireEncoder<'a, Q, S>
where Q: Unpin, S: Unpin,

§

impl<'a, Q, S> !UnwindSafe for WireEncoder<'a, Q, S>

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