From: Matt Corallo Date: Mon, 12 Feb 2024 00:03:14 +0000 (+0000) Subject: Expose constants for various supported record wire types X-Git-Tag: v0.5.4~62 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=f58a94e730c987e4da3114ff68420a4ef99a0f73;p=dnssec-prover Expose constants for various supported record wire types --- diff --git a/src/rr.rs b/src/rr.rs index 981d2b8..4761ddd 100644 --- a/src/rr.rs +++ b/src/rr.rs @@ -195,6 +195,8 @@ pub struct Txt { /// is an arbitrary series of bytes here. pub data: Vec, } +/// The wire type for TXT records +pub const TXT_TYPE: u16 = 16; impl PartialOrd for Txt { fn partial_cmp(&self, o: &Txt) -> Option { Some(self.name.cmp(&o.name) @@ -213,7 +215,7 @@ impl PartialOrd for Txt { } } impl StaticRecord for Txt { - const TYPE: u16 = 16; + const TYPE: u16 = TXT_TYPE; fn name(&self) -> &Name { &self.name } fn json(&self) -> String { if let Ok(s) = core::str::from_utf8(&self.data) { @@ -269,8 +271,10 @@ pub struct TLSA { /// The certificate data or hash of the certificate data itself. pub data: Vec, } +/// The wire type for TLSA records +pub const TLSA_TYPE: u16 = 52; impl StaticRecord for TLSA { - const TYPE: u16 = 52; + const TYPE: u16 = TLSA_TYPE; fn name(&self) -> &Name { &self.name } fn json(&self) -> String { let mut out = String::with_capacity(128+self.data.len()*2); @@ -535,8 +539,10 @@ pub struct A { /// The bytes of the IPv4 address. pub address: [u8; 4], } +/// The wire type for A records +pub const A_TYPE: u16 = 1; impl StaticRecord for A { - const TYPE: u16 = 1; + const TYPE: u16 = A_TYPE; fn name(&self) -> &Name { &self.name } fn json(&self) -> String { format!("{{\"type\":\"a\",\"name\":\"{}\",\"address\":{:?}}}", self.name.0, self.address) @@ -561,8 +567,10 @@ pub struct AAAA { /// The bytes of the IPv6 address. pub address: [u8; 16], } +/// The wire type for AAAA records +pub const AAAA_TYPE: u16 = 28; impl StaticRecord for AAAA { - const TYPE: u16 = 28; + const TYPE: u16 = AAAA_TYPE; fn name(&self) -> &Name { &self.name } fn json(&self) -> String { format!("{{\"type\":\"aaaa\",\"name\":\"{}\",\"address\":{:?}}}", self.name.0, self.address)