From e765b651f11f3bd8e09553c1bfd6f19007336ede Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Mon, 26 Feb 2024 20:44:08 +0000 Subject: [PATCH] Define a util method to convert a type value to the type's name --- src/rr.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/rr.rs b/src/rr.rs index 33fdb18..c464462 100644 --- 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 for RR { fn from(a: A) -> RR { RR::A(a) } } impl From for RR { fn from(aaaa: AAAA) -> RR { RR::AAAA(aaaa) } } -- 2.39.5