Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RequestInfo derives Clone trait. #1693

Merged
merged 1 commit into from
Apr 13, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions crates/server/src/server/request_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ impl std::ops::Deref for Request {
// TODO: add ProtocolInfo that would have TLS details or other additional things...
/// A narrow view of the Request, specifically a verified single query for the request
#[non_exhaustive]
#[derive(Clone)]
pub struct RequestInfo<'a> {
/// The source address from which the request came
pub src: SocketAddr,
Expand Down Expand Up @@ -148,3 +149,27 @@ pub trait RequestHandler: Send + Sync + Unpin + 'static {
response_handle: R,
) -> ResponseInfo;
}

#[cfg(test)]
mod tests {
use trust_dns_client::op::{Header, Query};

use crate::server::Protocol;

use super::RequestInfo;

#[test]
fn request_info_clone() {
let query: Query = Query::new();
let header = Header::new();
let lower_query = query.into();
let origin = RequestInfo::new(
"127.0.0.1:3000".parse().unwrap(),
Protocol::Udp,
&header,
&lower_query,
);
let cloned = origin.clone();
assert_eq!(origin.header, cloned.header);
}
}