pub fn response<'q, 'r>(
query: &'q [u8],
buffer: &'r mut dyn Buffer,
udp: bool,
) -> Result<Option<(Message<'q>, MessageBuilder<'r, Sink<'r>, QdSection>)>, ResponseError>Expand description
Starts building a new response (QR=1) for the given query (QR=0).
Returns the query view and response builder, or writes an error response to the given buffer
and returns None, or returns a MessageError if either of those fail.
The algorithm is as follows:
- If the query header is malformed, return an empty response with RCODE = FormErr
- Start a new response with the same ID + OPCODE + RD, defaulting to RCODE = NotImp
- If the query is well-formed and its EDNS version (if any) supported, return Ok(Some())
- If the query has any EDNS OPT RR, add EDNS OPT RR to the response
- If the query EDNS version is unimplemented, finish the response with RCODE = BADVERS
- If the query is otherwise malformed, finish the response with RCODE = FormErr
- Return Ok(None)