]> git.bitcoin.ninja Git - dnssec-prover/commitdiff
Define a util method to convert a type value to the type's name
authorMatt Corallo <git@bluematt.me>
Mon, 26 Feb 2024 20:44:08 +0000 (20:44 +0000)
committerMatt Corallo <git@bluematt.me>
Mon, 26 Feb 2024 20:44:36 +0000 (20:44 +0000)
src/rr.rs

index 33fdb188f26f0be2fb3be95e50a9a16797315b16..c464462e0d30a91b359721ed9826176d424d0b96 100644 (file)
--- a/src/rr.rs
+++ b/src/rr.rs
@@ -161,6 +161,23 @@ impl RR {
                        RR::RRSig(rr) => StaticRecord::write_u16_len_prefixed_data(rr, out),
                }
        }
+       fn ty_to_rr_name(ty: u16) -> Option<&'static str> {
+               match ty {
+                       A::TYPE => Some("A"),
+                       AAAA::TYPE => Some("AAAA"),
+                       NS::TYPE => Some("NS"),
+                       Txt::TYPE => Some("TXT"),
+                       CName::TYPE => Some("CNAME"),
+                       DName::TYPE => Some("DNAME"),
+                       TLSA::TYPE => Some("TLSA"),
+                       DnsKey::TYPE => Some("DNSKEY"),
+                       DS::TYPE => Some("DS"),
+                       RRSig::TYPE => Some("RRSIG"),
+                       NSec::TYPE => Some("NSEC"),
+                       NSec3::TYPE => Some("NSEC3"),
+                       _ => None,
+               }
+       }
 }
 impl From<A> for RR { fn from(a: A) -> RR { RR::A(a) } }
 impl From<AAAA> for RR { fn from(aaaa: AAAA) -> RR { RR::AAAA(aaaa) } }