diff --git a/src/base/record.rs b/src/base/record.rs index 132ebb5c5..8fae9b656 100644 --- a/src/base/record.rs +++ b/src/base/record.rs @@ -244,6 +244,14 @@ impl From<(N, u32, D)> for Record { } } +//--- AsRef + +impl AsRef> for Record { + fn as_ref(&self) -> &Record { + self + } +} + //--- OctetsFrom and FlattenInto // // XXX We don’t have blanket FromOctets for a type T into itself, so this may diff --git a/src/rdata/zonemd.rs b/src/rdata/zonemd.rs index e151584ae..cce3c5394 100644 --- a/src/rdata/zonemd.rs +++ b/src/rdata/zonemd.rs @@ -114,7 +114,7 @@ impl Zonemd { } pub(super) fn flatten>( - self + self, ) -> Result, Target::Error> { self.convert_octets() } @@ -361,8 +361,6 @@ mod test { use crate::base::rdata::test::{ test_compose_parse, test_rdlen, test_scan, }; - use crate::base::Dname; - use crate::rdata::ZoneRecordData; use crate::utils::base16::decode; use std::string::ToString; use std::vec::Vec; @@ -393,6 +391,8 @@ mod test { #[cfg(feature = "zonefile")] #[test] fn zonemd_parse_zonefile() { + use crate::base::Dname; + use crate::rdata::ZoneRecordData; use crate::zonefile::inplace::{Entry, Zonefile}; // section A.1 diff --git a/src/utils/base64.rs b/src/utils/base64.rs index beb840e5a..be60376d7 100644 --- a/src/utils/base64.rs +++ b/src/utils/base64.rs @@ -306,7 +306,6 @@ impl Decoder { //--- Default -#[cfg(feature = "bytes")] impl Default for Decoder { fn default() -> Self { Self::new() diff --git a/src/validate.rs b/src/validate.rs index f23163e24..25d0cc4a2 100644 --- a/src/validate.rs +++ b/src/validate.rs @@ -112,7 +112,7 @@ pub trait RrsigExt { fn signed_data( &self, buf: &mut B, - records: &mut [Record], + records: &mut [impl AsRef>], ) -> Result<(), B::AppendError> where D: CanonicalOrd + ComposeRecordData + Sized; @@ -149,7 +149,7 @@ impl, Name: ToDname> RrsigExt for Rrsig { fn signed_data( &self, buf: &mut B, - records: &mut [Record], + records: &mut [impl AsRef>], ) -> Result<(), B::AppendError> where D: CanonicalOrd + ComposeRecordData + Sized, @@ -170,10 +170,12 @@ impl, Name: ToDname> RrsigExt for Rrsig { // The set of all RR(i) is sorted into canonical order. // See https://tools.ietf.org/html/rfc4034#section-6.3 - records.sort_by(|a, b| a.data().canonical_cmp(b.data())); + records.sort_by(|a, b| { + a.as_ref().data().canonical_cmp(b.as_ref().data()) + }); // RR(i) = name | type | class | OrigTTL | RDATA length | RDATA - for rr in records { + for rr in records.iter().map(|r| r.as_ref()) { // Handle expanded wildcards as per [RFC4035, Section 5.3.2] // (https://tools.ietf.org/html/rfc4035#section-5.3.2). let rrsig_labels = usize::from(self.labels());