Skip to content

Commit

Permalink
RequestInfo derives Clone trait.
Browse files Browse the repository at this point in the history
  • Loading branch information
humb1t authored and bluejekyll committed Apr 13, 2022
1 parent 93a2114 commit 261a7a8
Showing 1 changed file with 25 additions and 0 deletions.
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);
}
}

0 comments on commit 261a7a8

Please sign in to comment.