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>
impl<'a, Q: QueryOrResponse> WireEncoder<'a, Q, QuestionSection>
Sourcepub fn finalize_questions(self) -> WireEncoder<'a, Q, AnswerSection>
pub fn finalize_questions(self) -> WireEncoder<'a, Q, AnswerSection>
Transitions the encoder into a state for encoding answers.
pub fn encode_question<'b, F: Format<'b>>( &mut self, q: &'b Question<'b, F>, ) -> Result<(), EncoderError>
Source§impl<'a> WireEncoder<'a, Query, QuestionSection>
impl<'a> WireEncoder<'a, Query, QuestionSection>
Source§impl<'a> WireEncoder<'a, Response, AnswerSection>
impl<'a> WireEncoder<'a, Response, AnswerSection>
Sourcepub fn new_response(
buffer: &'a mut [u8],
request: &WireMessage<'_>,
) -> Result<Self, EncoderError>
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.
pub fn finalize_answers(self) -> WireEncoder<'a, Response, AuthoritySection>
pub fn encode_answer<'b, F: Format<'b>>( &mut self, r: &'b ResourceRecord<'b, F>, ) -> Result<(), EncoderError>
Source§impl<'a> WireEncoder<'a, Response, AuthoritySection>
impl<'a> WireEncoder<'a, Response, AuthoritySection>
Source§impl<'a> WireEncoder<'a, Response, AdditionalSection>
impl<'a> WireEncoder<'a, Response, AdditionalSection>
pub fn finalize_additionals(self) -> WireEncoder<'a, Response, Done>
pub fn encode_additional<'b, F: Format<'b>>( &mut self, r: &'b ResourceRecord<'b, F>, ) -> Result<(), EncoderError>
Trait Implementations§
Source§impl<'a, Q: Debug + QueryOrResponse, S: Debug + EncoderState> Debug for WireEncoder<'a, Q, S>
impl<'a, Q: Debug + QueryOrResponse, S: Debug + EncoderState> Debug for WireEncoder<'a, Q, S>
Source§impl<'a, Q: PartialEq + QueryOrResponse, S: PartialEq + EncoderState> PartialEq for WireEncoder<'a, Q, S>
impl<'a, Q: PartialEq + QueryOrResponse, S: PartialEq + EncoderState> PartialEq for WireEncoder<'a, Q, S>
impl<'a, Q: Eq + QueryOrResponse, S: Eq + EncoderState> Eq for WireEncoder<'a, Q, S>
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>where
Q: RefUnwindSafe,
S: RefUnwindSafe,
impl<'a, Q, S> Send for WireEncoder<'a, Q, S>
impl<'a, Q, S> Sync for WireEncoder<'a, Q, S>
impl<'a, Q, S> Unpin for WireEncoder<'a, Q, S>
impl<'a, Q, S> !UnwindSafe for WireEncoder<'a, Q, S>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more