pub struct MessageResponseBuilder<'q> { /* private fields */ }Expand description
A builder for MessageResponses
Implementations§
Source§impl<'q> MessageResponseBuilder<'q>
impl<'q> MessageResponseBuilder<'q>
Sourcepub fn new(queries: &'q Queries, edns: Option<&'q Edns>) -> Self
pub fn new(queries: &'q Queries, edns: Option<&'q Edns>) -> Self
Constructs a new response builder
§Arguments
queries- queries (from the Request) to associate with the Responseedns- Optional Edns data to associate with the Response
Sourcepub fn from_message_request(message: &'q MessageRequest) -> Self
pub fn from_message_request(message: &'q MessageRequest) -> Self
Constructs a new response builder
§Arguments
message- original request message to associate with the response
§Example
use hickory_proto::{op::ResponseCode, rr::Record};
use hickory_server::{
server::Request,
zone_handler::{MessageResponse, MessageResponseBuilder},
};
fn handle_request<'q>(request: &'q Request) -> MessageResponse<
'q,
'static,
impl Iterator<Item = &'static Record> + Send + 'static,
impl Iterator<Item = &'static Record> + Send + 'static,
impl Iterator<Item = &'static Record> + Send + 'static,
impl Iterator<Item = &'static Record> + Send + 'static,
> {
MessageResponseBuilder::from_message_request(request)
.error_msg(&request.metadata, ResponseCode::ServFail)
}Sourcepub fn build<'a, A, N, S, D>(
self,
metadata: Metadata,
answers: A,
authorities: N,
soa: S,
additionals: D,
) -> MessageResponse<'q, 'a, A::IntoIter, N::IntoIter, S::IntoIter, D::IntoIter>where
A: IntoIterator<Item = &'a Record> + Send + 'a,
A::IntoIter: Send,
N: IntoIterator<Item = &'a Record> + Send + 'a,
N::IntoIter: Send,
S: IntoIterator<Item = &'a Record> + Send + 'a,
S::IntoIter: Send,
D: IntoIterator<Item = &'a Record> + Send + 'a,
D::IntoIter: Send,
pub fn build<'a, A, N, S, D>(
self,
metadata: Metadata,
answers: A,
authorities: N,
soa: S,
additionals: D,
) -> MessageResponse<'q, 'a, A::IntoIter, N::IntoIter, S::IntoIter, D::IntoIter>where
A: IntoIterator<Item = &'a Record> + Send + 'a,
A::IntoIter: Send,
N: IntoIterator<Item = &'a Record> + Send + 'a,
N::IntoIter: Send,
S: IntoIterator<Item = &'a Record> + Send + 'a,
S::IntoIter: Send,
D: IntoIterator<Item = &'a Record> + Send + 'a,
D::IntoIter: Send,
Constructs the new MessageResponse with associated data
Sourcepub fn build_no_records<'a>(
self,
metadata: Metadata,
) -> MessageResponse<'q, 'a, impl Iterator<Item = &'a Record> + Send + 'a, impl Iterator<Item = &'a Record> + Send + 'a, impl Iterator<Item = &'a Record> + Send + 'a, impl Iterator<Item = &'a Record> + Send + 'a>
pub fn build_no_records<'a>( self, metadata: Metadata, ) -> MessageResponse<'q, 'a, impl Iterator<Item = &'a Record> + Send + 'a, impl Iterator<Item = &'a Record> + Send + 'a, impl Iterator<Item = &'a Record> + Send + 'a, impl Iterator<Item = &'a Record> + Send + 'a>
Construct a Response with no associated records
Sourcepub fn error_msg<'a>(
self,
request_meta: &Metadata,
response_code: ResponseCode,
) -> MessageResponse<'q, 'a, impl Iterator<Item = &'a Record> + Send + 'a, impl Iterator<Item = &'a Record> + Send + 'a, impl Iterator<Item = &'a Record> + Send + 'a, impl Iterator<Item = &'a Record> + Send + 'a>
pub fn error_msg<'a>( self, request_meta: &Metadata, response_code: ResponseCode, ) -> MessageResponse<'q, 'a, impl Iterator<Item = &'a Record> + Send + 'a, impl Iterator<Item = &'a Record> + Send + 'a, impl Iterator<Item = &'a Record> + Send + 'a, impl Iterator<Item = &'a Record> + Send + 'a>
Constructs a new error MessageResponse with associated header and response code
Auto Trait Implementations§
impl<'q> Freeze for MessageResponseBuilder<'q>
impl<'q> RefUnwindSafe for MessageResponseBuilder<'q>
impl<'q> Send for MessageResponseBuilder<'q>
impl<'q> Sync for MessageResponseBuilder<'q>
impl<'q> Unpin for MessageResponseBuilder<'q>
impl<'q> UnsafeUnpin for MessageResponseBuilder<'q>
impl<'q> UnwindSafe for MessageResponseBuilder<'q>
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more