Skip to content

Commit

Permalink
refactor: rewrite to Option type rrtype
Browse files Browse the repository at this point in the history
  • Loading branch information
joalopez1206 committed Sep 5, 2024
1 parent 6476e4e commit 14447f1
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/resolver_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ impl ResolverCache {
qtype: Rrtype,
qclass: Rclass,
) -> Option<Vec<ResourceRecord>> {
let rr_stored_data = self.cache_answer.get(domain_name, qtype, qclass);
let rr_stored_data = self.cache_answer.get(domain_name, Some(qtype), qclass);

if let Some(rr_stored_data) = rr_stored_data {
let mut rr_vec = Vec::new();
Expand All @@ -199,7 +199,7 @@ impl ResolverCache {
qtype: Rrtype,
qclass: Rclass,
) -> Option<Vec<ResourceRecord>> {
let rr_stored_data = self.cache_authority.get(domain_name, qtype, qclass);
let rr_stored_data = self.cache_authority.get(domain_name, Some(qtype), qclass);

if let Some(rr_stored_data) = rr_stored_data {
let mut rr_vec = Vec::new();
Expand All @@ -219,7 +219,7 @@ impl ResolverCache {
qtype: Rrtype,
qclass: Rclass,
) -> Option<Vec<ResourceRecord>> {
let rr_stored_data = self.cache_additional.get(domain_name, qtype, qclass);
let rr_stored_data = self.cache_additional.get(domain_name, Some(qtype), qclass);

if let Some(rr_stored_data) = rr_stored_data {
let mut rr_vec = Vec::new();
Expand All @@ -238,7 +238,7 @@ impl ResolverCache {
qtype: Rrtype,
qclass: Rclass,
) -> Option<Rcode> {
let rr_stored_data = self.cache_answer.get(domain_name, qtype, qclass);
let rr_stored_data = self.cache_answer.get(domain_name, Some(qtype), qclass);

if let Some(rr_stored_data) = rr_stored_data {
Some(rr_stored_data[0].get_rcode())
Expand Down Expand Up @@ -515,7 +515,7 @@ mod resolver_cache_test {

let rr = resolver_cache
.cache_answer
.get(domain_name.clone(), Rrtype::A, Rclass::IN)
.get(domain_name.clone(), Some(Rrtype::A), Rclass::IN)
.unwrap();

assert_eq!(rr[0].get_resource_record(), resource_record);
Expand Down Expand Up @@ -547,7 +547,7 @@ mod resolver_cache_test {

let rr = resolver_cache
.cache_authority
.get(domain_name.clone(), Rrtype::A, Rclass::IN)
.get(domain_name.clone(), Some(Rrtype::A), Rclass::IN)
.unwrap();

assert_eq!(rr[0].get_resource_record(), resource_record);
Expand Down Expand Up @@ -579,7 +579,7 @@ mod resolver_cache_test {

let rr = resolver_cache
.cache_additional
.get(domain_name.clone(), Rrtype::A, Rclass::IN)
.get(domain_name.clone(), Some(Rrtype::A), Rclass::IN)
.unwrap();

assert_eq!(rr[0].get_resource_record(), resource_record);
Expand Down Expand Up @@ -647,15 +647,15 @@ mod resolver_cache_test {

let rr_answer = resolver_cache
.cache_answer
.get(domain_name.clone(), Rrtype::A, Rclass::IN)
.get(domain_name.clone(), Some(Rrtype::A), Rclass::IN)
.unwrap();
let rr_authority = resolver_cache
.cache_authority
.get(domain_name.clone(), Rrtype::A, Rclass::IN)
.get(domain_name.clone(), Some(Rrtype::A), Rclass::IN)
.unwrap();
let rr_additional = resolver_cache
.cache_additional
.get(domain_name.clone(), Rrtype::A, Rclass::IN)
.get(domain_name.clone(), Some(Rrtype::A), Rclass::IN)
.unwrap();

assert_eq!(rr_answer[0].get_resource_record(), resource_record_1);
Expand Down Expand Up @@ -1320,15 +1320,15 @@ mod resolver_cache_test {

let rr_answer = resolver_cache
.cache_answer
.get(domain_name.clone(), Rrtype::A, Rclass::IN);
.get(domain_name.clone(), Some(Rrtype::A), Rclass::IN);
let rr_authority =
resolver_cache
.cache_authority
.get(domain_name.clone(), Rrtype::A, Rclass::IN);
.get(domain_name.clone(), Some(Rrtype::A), Rclass::IN);
let rr_additional =
resolver_cache
.cache_additional
.get(domain_name.clone(), Rrtype::A, Rclass::IN);
.get(domain_name.clone(), Some(Rrtype::A), Rclass::IN);

assert_eq!(rr_answer, None);
assert_eq!(rr_authority, None);
Expand Down

0 comments on commit 14447f1

Please sign in to comment.