mark ResolverOpts and DnsRequestOptions as non_exhaustive
This commit is contained in:
parent
d611c5890a
commit
3f270a0aae
@ -29,7 +29,7 @@ pub(crate) trait RDataParser: Sized {
|
||||
) -> ParseResult<Self>;
|
||||
}
|
||||
|
||||
#[warn(clippy::wildcard_enum_match_arm)] // make sure all cases are handled despite of non_exhaustive
|
||||
#[warn(clippy::wildcard_enum_match_arm)] // make sure all cases are handled
|
||||
impl RDataParser for RData {
|
||||
/// Parse the RData from a set of Tokens
|
||||
fn parse<'i, I: Iterator<Item = &'i str>>(
|
||||
|
@ -13,6 +13,7 @@ use crate::op::Message;
|
||||
|
||||
/// A set of options for expressing options to how requests should be treated
|
||||
#[derive(Clone, Copy, Debug, Default)]
|
||||
#[non_exhaustive]
|
||||
pub struct DnsRequestOptions {
|
||||
/// When true, the underlying DNS protocols will not return on the first response received.
|
||||
///
|
||||
|
@ -90,15 +90,10 @@ macro_rules! lookup_fn {
|
||||
}
|
||||
};
|
||||
|
||||
self.inner_lookup(
|
||||
name,
|
||||
$r,
|
||||
DnsRequestOptions {
|
||||
use_edns: self.options.edns0,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.await
|
||||
let mut request_opts = DnsRequestOptions::default();
|
||||
request_opts.use_edns = self.options.edns0;
|
||||
|
||||
self.inner_lookup(name, $r, request_opts).await
|
||||
}
|
||||
};
|
||||
($p:ident, $l:ty, $r:path, $t:ty) => {
|
||||
|
@ -698,6 +698,7 @@ impl Default for LookupIpStrategy {
|
||||
serde(default)
|
||||
)]
|
||||
#[allow(dead_code)] // TODO: remove after all params are supported
|
||||
#[non_exhaustive]
|
||||
pub struct ResolverOpts {
|
||||
/// Sets the number of dots that must appear (unless it's a final dot representing the root)
|
||||
/// that must appear before a query is assumed to include the TLD. The default is one, which
|
||||
|
@ -47,12 +47,11 @@ impl<C: DnsHandle<Error = ResolveError>, P: ConnectionProvider<Conn = C>> DnsSdH
|
||||
let this = self.clone();
|
||||
|
||||
let ptr_future = async move {
|
||||
let options = DnsRequestOptions {
|
||||
expects_multiple_responses: true,
|
||||
// TODO: This should use the AsyncResolver's options.edns0
|
||||
// setting, but options is private.
|
||||
use_edns: false,
|
||||
};
|
||||
let mut options = DnsRequestOptions::default();
|
||||
options.expects_multiple_responses = true;
|
||||
// TODO: This should use the AsyncResolver's options.edns0
|
||||
// setting, but options is private.
|
||||
options.use_edns = false;
|
||||
|
||||
this.inner_lookup(name, RecordType::PTR, options).await
|
||||
};
|
||||
|
@ -403,11 +403,10 @@ where
|
||||
|
||||
#[test]
|
||||
fn test_concurrent_requests_2_conns() {
|
||||
let options = ResolverOpts {
|
||||
// there are only 2 conns, so this matches that count
|
||||
num_concurrent_reqs: 2,
|
||||
..Default::default()
|
||||
};
|
||||
let mut options = ResolverOpts::default();
|
||||
|
||||
// there are only 2 conns, so this matches that count
|
||||
options.num_concurrent_reqs = 2;
|
||||
|
||||
// we want to make sure that both udp connections are called
|
||||
// this will count down to 0 only if both are called.
|
||||
@ -445,11 +444,10 @@ fn test_concurrent_requests_2_conns() {
|
||||
|
||||
#[test]
|
||||
fn test_concurrent_requests_more_than_conns() {
|
||||
let options = ResolverOpts {
|
||||
// there are only two conns, but this requests 3 concurrent requests, only 2 called
|
||||
num_concurrent_reqs: 3,
|
||||
..Default::default()
|
||||
};
|
||||
let mut options = ResolverOpts::default();
|
||||
|
||||
// there are only two conns, but this requests 3 concurrent requests, only 2 called
|
||||
options.num_concurrent_reqs = 3;
|
||||
|
||||
// we want to make sure that both udp connections are called
|
||||
// this will count down to 0 only if both are called.
|
||||
@ -487,11 +485,10 @@ fn test_concurrent_requests_more_than_conns() {
|
||||
|
||||
#[test]
|
||||
fn test_concurrent_requests_1_conn() {
|
||||
let options = ResolverOpts {
|
||||
// there are two connections, but no concurrency requested
|
||||
num_concurrent_reqs: 1,
|
||||
..Default::default()
|
||||
};
|
||||
let mut options = ResolverOpts::default();
|
||||
|
||||
// there are two connections, but no concurrency requested
|
||||
options.num_concurrent_reqs = 1;
|
||||
|
||||
// we want to make sure that both udp connections are called
|
||||
// this will count down to 0 only if both are called.
|
||||
@ -529,11 +526,10 @@ fn test_concurrent_requests_1_conn() {
|
||||
|
||||
#[test]
|
||||
fn test_concurrent_requests_0_conn() {
|
||||
let options = ResolverOpts {
|
||||
// there are two connections, but no concurrency requested, 0==1
|
||||
num_concurrent_reqs: 0,
|
||||
..Default::default()
|
||||
};
|
||||
let mut options = ResolverOpts::default();
|
||||
|
||||
// there are two connections, but no concurrency requested, 0==1
|
||||
options.num_concurrent_reqs = 0;
|
||||
|
||||
// we want to make sure that both udp connections are called
|
||||
// this will count down to 0 only if both are called.
|
||||
|
Loading…
Reference in New Issue
Block a user