domain::base::cmp

Trait CanonicalOrd

source
pub trait CanonicalOrd<Rhs: ?Sized = Self> {
    // Required method
    fn canonical_cmp(&self, other: &Rhs) -> Ordering;

    // Provided methods
    fn canonical_lt(&self, other: &Rhs) -> bool { ... }
    fn canonical_le(&self, other: &Rhs) -> bool { ... }
    fn canonical_gt(&self, other: &Rhs) -> bool { ... }
    fn canonical_ge(&self, other: &Rhs) -> bool { ... }
}
Expand description

A trait for the canonical sort order of values.

The canonical sort order is used in DNSSEC when multiple values are part of constructing or validating a signature. This sort order differs in some cases from the normal sort order. To avoid confusion, only this trait should be used when DNSSEC signatures are involved.

Canonical order is defined in RFC 4034 and clarified in RFC 6840. It is defined for domain names and resource records within an RR set (i.e., a set of records with the same owner name, class, and type).

For domain names, canonical order is the same as the ‘normal’ order as implemented through the PartialOrd and Ord traits: labels are compared from right to left (i.e, starting from the root label) with each pair of labels compared as octet sequences with ASCII letters lowercased before comparison. The ToName::name_cmp and ToRelativeName::name_cmp methods of the can be used to implement this canonical order for name types.

Resource records within an RR set are ordered by comparing the canonical wire-format representation of their record data as octet sequences. The canonical form differs from the regular form by lower-casing domain names included in the record data for the record types NS, MD, MF, CNAME, SOA, MB, MG, MR, PTR, MINFO, MX, RP, AFSDB, RT, SIG, PX, NXT, NAPTR, KX, SRV, DNAME, A6, and RRSIG. (NSEC is listed in RFC 4034 but has been withdrawn by RFC 6840). This canonical representation is provided via their respective compose_canonical methods.

In order to help implementing this trait for record data types, there are implementations of it for some types that can appear in record data that sort differently in their composed representation than normally.

Apart from these explicit use cases, the CanonicalOrd trait is also implemented for the Record type to allow ordering records of a zone into RRsets. It does so by ordering by class first, then canonical owner, record type, and finally canonical record data. The reason for this somewhat odd ordering is that in this way not only are all records for the same owner name and class kept together, but also all the records subordinate to a owner name and class pair (i.e., the records for a zone) will sort together.

Required Methods§

source

fn canonical_cmp(&self, other: &Rhs) -> Ordering

Returns the canonical ordering between self and other.

Provided Methods§

source

fn canonical_lt(&self, other: &Rhs) -> bool

Returns whether self is canonically less than other.

source

fn canonical_le(&self, other: &Rhs) -> bool

Returns whether self is canonically less than or equal to other.

source

fn canonical_gt(&self, other: &Rhs) -> bool

Returns whether self is canonically greater than other.

source

fn canonical_ge(&self, other: &Rhs) -> bool

Returns whether self is canonically greater than or equal to other.

Implementors§

source§

impl CanonicalOrd for Aaaa

source§

impl CanonicalOrd for Timestamp

source§

impl CanonicalOrd for A

source§

impl CanonicalOrd for Serial

source§

impl<N, NN> CanonicalOrd<Question<NN>> for Question<N>
where N: ToName, NN: ToName,

source§

impl<N, NN, D, DD> CanonicalOrd<Record<NN, DD>> for Record<N, D>
where N: ToName, NN: ToName, D: RecordData + CanonicalOrd<DD>, DD: RecordData,

source§

impl<N, NN, O, OO> CanonicalOrd<Rrsig<OO, NN>> for Rrsig<O, N>
where N: ToName, NN: ToName, O: AsRef<[u8]>, OO: AsRef<[u8]>,

source§

impl<N: ToName, NN: ToName> CanonicalOrd<Dname<NN>> for Dname<N>

source§

impl<N: ToName, NN: ToName> CanonicalOrd<Cname<NN>> for Cname<N>

source§

impl<N: ToName, NN: ToName> CanonicalOrd<Mb<NN>> for Mb<N>

source§

impl<N: ToName, NN: ToName> CanonicalOrd<Md<NN>> for Md<N>

source§

impl<N: ToName, NN: ToName> CanonicalOrd<Mf<NN>> for Mf<N>

source§

impl<N: ToName, NN: ToName> CanonicalOrd<Mg<NN>> for Mg<N>

source§

impl<N: ToName, NN: ToName> CanonicalOrd<Minfo<NN>> for Minfo<N>

source§

impl<N: ToName, NN: ToName> CanonicalOrd<Mr<NN>> for Mr<N>

source§

impl<N: ToName, NN: ToName> CanonicalOrd<Mx<NN>> for Mx<N>

source§

impl<N: ToName, NN: ToName> CanonicalOrd<Ns<NN>> for Ns<N>

source§

impl<N: ToName, NN: ToName> CanonicalOrd<Ptr<NN>> for Ptr<N>

source§

impl<N: ToName, NN: ToName> CanonicalOrd<Soa<NN>> for Soa<N>

source§

impl<N: ToName, NN: ToName> CanonicalOrd<Srv<NN>> for Srv<N>

source§

impl<O, OO> CanonicalOrd<RtypeBitmap<OO>> for RtypeBitmap<O>
where O: AsRef<[u8]>, OO: AsRef<[u8]>,

source§

impl<O, OO, N, NN> CanonicalOrd<AllRecordData<OO, NN>> for AllRecordData<O, N>
where O: AsRef<[u8]>, OO: AsRef<[u8]>, N: CanonicalOrd<NN> + ToName, NN: ToName,

source§

impl<O, OO, N, NN> CanonicalOrd<ZoneRecordData<OO, NN>> for ZoneRecordData<O, N>
where O: AsRef<[u8]>, OO: AsRef<[u8]>, N: CanonicalOrd<NN> + ToName, NN: ToName,

source§

impl<O, OO, N, NN> CanonicalOrd<Nsec<OO, NN>> for Nsec<O, N>
where O: AsRef<[u8]>, OO: AsRef<[u8]>, N: ToName, NN: ToName,

source§

impl<O, OO, N, NN> CanonicalOrd<Tsig<OO, NN>> for Tsig<O, N>
where O: AsRef<[u8]>, OO: AsRef<[u8]>, N: ToName, NN: ToName,

source§

impl<Octs, N> CanonicalOrd<N> for Name<Octs>
where Octs: AsRef<[u8]> + ?Sized, N: ToName + ?Sized,

source§

impl<Octs, N> CanonicalOrd<N> for ParsedName<Octs>
where Octs: AsRef<[u8]>, N: ToName + ?Sized,

source§

impl<Octs, Other> CanonicalOrd<Cdnskey<Other>> for Cdnskey<Octs>
where Octs: AsRef<[u8]>, Other: AsRef<[u8]>,

source§

impl<Octs, Other> CanonicalOrd<Cds<Other>> for Cds<Octs>
where Octs: AsRef<[u8]>, Other: AsRef<[u8]>,

source§

impl<Octs, Other> CanonicalOrd<Dnskey<Other>> for Dnskey<Octs>
where Octs: AsRef<[u8]>, Other: AsRef<[u8]>,

source§

impl<Octs, Other> CanonicalOrd<Ds<Other>> for Ds<Octs>
where Octs: AsRef<[u8]>, Other: AsRef<[u8]>,

source§

impl<Octs, Other> CanonicalOrd<Nsec3<Other>> for Nsec3<Octs>
where Octs: AsRef<[u8]>, Other: AsRef<[u8]>,

source§

impl<Octs, Other> CanonicalOrd<Nsec3param<Other>> for Nsec3param<Octs>
where Octs: AsRef<[u8]>, Other: AsRef<[u8]>,

source§

impl<Octs, Other> CanonicalOrd<Hinfo<Other>> for Hinfo<Octs>
where Octs: AsRef<[u8]>, Other: AsRef<[u8]>,

source§

impl<Octs, Other> CanonicalOrd<Null<Other>> for Null<Octs>
where Octs: AsRef<[u8]> + ?Sized, Other: AsRef<[u8]> + ?Sized,

source§

impl<Octs, Other> CanonicalOrd<Txt<Other>> for Txt<Octs>
where Octs: AsRef<[u8]>, Other: AsRef<[u8]>,

source§

impl<Octs, Other> CanonicalOrd<Zonemd<Other>> for Zonemd<Octs>
where Octs: AsRef<[u8]>, Other: AsRef<[u8]>,

source§

impl<Octs, Other> CanonicalOrd<Opt<Other>> for Opt<Octs>
where Octs: AsRef<[u8]> + ?Sized, Other: AsRef<[u8]> + ?Sized,

source§

impl<Octs, Other> CanonicalOrd<UnknownRecordData<Other>> for UnknownRecordData<Octs>
where Octs: AsRef<[u8]>, Other: AsRef<[u8]>,

source§

impl<Octs, OtherOcts> CanonicalOrd<SvcParams<OtherOcts>> for SvcParams<Octs>
where Octs: AsRef<[u8]> + ?Sized, OtherOcts: AsRef<[u8]> + ?Sized,

source§

impl<T, U> CanonicalOrd<Nsec3Salt<U>> for Nsec3Salt<T>
where T: AsRef<[u8]> + ?Sized, U: AsRef<[u8]> + ?Sized,

source§

impl<T, U> CanonicalOrd<OwnerHash<U>> for OwnerHash<T>
where T: AsRef<[u8]> + ?Sized, U: AsRef<[u8]> + ?Sized,

source§

impl<T, U> CanonicalOrd<CharStr<U>> for CharStr<T>
where T: AsRef<[u8]> + ?Sized, U: AsRef<[u8]> + ?Sized,

source§

impl<Variant, OtherVariant, Octs, OtherOcts, Name, OtherName> CanonicalOrd<SvcbRdata<OtherVariant, OtherOcts, OtherName>> for SvcbRdata<Variant, Octs, Name>
where Octs: AsRef<[u8]>, OtherOcts: AsRef<[u8]>, Name: ToName, OtherName: ToName,