pub trait ToDname: ToLabelIter {
Show 13 methods
// Provided methods
fn to_dname<Octets>(&self) -> Result<Dname<Octets>, PushError>
where Octets: FromBuilder,
<Octets as FromBuilder>::Builder: EmptyBuilder { ... }
fn to_canonical_dname<Octets>(&self) -> Result<Dname<Octets>, PushError>
where Octets: FromBuilder,
<Octets as FromBuilder>::Builder: EmptyBuilder { ... }
fn as_flat_slice(&self) -> Option<&[u8]> { ... }
fn compose<Target: OctetsBuilder + ?Sized>(
&self,
target: &mut Target
) -> Result<(), Target::AppendError> { ... }
fn compose_canonical<Target: OctetsBuilder + ?Sized>(
&self,
target: &mut Target
) -> Result<(), Target::AppendError> { ... }
fn to_cow(&self) -> Dname<Cow<'_, [u8]>> { ... }
fn to_vec(&self) -> Dname<Vec<u8>> { ... }
fn to_bytes(&self) -> Dname<Bytes> { ... }
fn name_eq<N: ToDname + ?Sized>(&self, other: &N) -> bool { ... }
fn name_cmp<N: ToDname + ?Sized>(&self, other: &N) -> Ordering { ... }
fn composed_cmp<N: ToDname + ?Sized>(&self, other: &N) -> Ordering { ... }
fn lowercase_composed_cmp<N: ToDname + ?Sized>(&self, other: &N) -> Ordering { ... }
fn rrsig_label_count(&self) -> u8 { ... }
}
Expand description
A type that represents an absolute domain name.
An absolute domain name is a sequence of labels where the last label is the root label and where the wire-format representation is not longer than 255 characters. Implementers of this trait need to provide access to the label sequence via an iterator and know how to compose the wire-format representation into a buffer.
The most common types implementing this trait are Dname
,
ParsedDname
, and Chain<L, R>
where R
is ToDname
itself.
Provided Methods§
sourcefn to_dname<Octets>(&self) -> Result<Dname<Octets>, PushError>where
Octets: FromBuilder,
<Octets as FromBuilder>::Builder: EmptyBuilder,
fn to_dname<Octets>(&self) -> Result<Dname<Octets>, PushError>where Octets: FromBuilder, <Octets as FromBuilder>::Builder: EmptyBuilder,
Converts the name into a single, uncompressed name.
The default implementation provided by the trait iterates over the
labels of the name and adds them one by one to Dname
. This will
work for any name but an optimized implementation can be provided for
some types of names.
sourcefn to_canonical_dname<Octets>(&self) -> Result<Dname<Octets>, PushError>where
Octets: FromBuilder,
<Octets as FromBuilder>::Builder: EmptyBuilder,
fn to_canonical_dname<Octets>(&self) -> Result<Dname<Octets>, PushError>where Octets: FromBuilder, <Octets as FromBuilder>::Builder: EmptyBuilder,
Converts the name into a single name in canonical form.
sourcefn as_flat_slice(&self) -> Option<&[u8]>
fn as_flat_slice(&self) -> Option<&[u8]>
Returns an octets slice of the content if possible.
If a value stores the domain name as one single octets sequence, it
should return a reference to this sequence here. If the name is
composed from multiple such sequences, it should return None
.
This method is used to optimize comparision operations between two values that are indeed flat names.
fn compose<Target: OctetsBuilder + ?Sized>( &self, target: &mut Target ) -> Result<(), Target::AppendError>
fn compose_canonical<Target: OctetsBuilder + ?Sized>( &self, target: &mut Target ) -> Result<(), Target::AppendError>
sourcefn to_cow(&self) -> Dname<Cow<'_, [u8]>>
fn to_cow(&self) -> Dname<Cow<'_, [u8]>>
Returns a cow of the domain name.
If the name is available as one single slice – i.e.,
as_flat_slice
returns ‘some,’ creates the borrowed variant from
that slice. Otherwise assembles an owned variant via to_dname
.
sourcefn name_eq<N: ToDname + ?Sized>(&self, other: &N) -> bool
fn name_eq<N: ToDname + ?Sized>(&self, other: &N) -> bool
Tests whether self
and other
are equal.
This method can be used to implement PartialEq
on types implementing
ToDname
since a blanket implementation for all pairs of ToDname
is currently impossible.
Domain names are compared ignoring ASCII case.
sourcefn name_cmp<N: ToDname + ?Sized>(&self, other: &N) -> Ordering
fn name_cmp<N: ToDname + ?Sized>(&self, other: &N) -> Ordering
Returns the ordering between self
and other
.
This method can be used to implement both PartialOrd
and Ord
on
types implementing ToDname
since a blanket implementation for all
pairs of ToDname
s is currently not possible.
Domain name order is determined according to the ‘canonical DNS name order’ as defined in section 6.1 of RFC 4034.
sourcefn composed_cmp<N: ToDname + ?Sized>(&self, other: &N) -> Ordering
fn composed_cmp<N: ToDname + ?Sized>(&self, other: &N) -> Ordering
Returns the composed name ordering.
sourcefn lowercase_composed_cmp<N: ToDname + ?Sized>(&self, other: &N) -> Ordering
fn lowercase_composed_cmp<N: ToDname + ?Sized>(&self, other: &N) -> Ordering
Returns the lowercase composed ordering.
sourcefn rrsig_label_count(&self) -> u8
fn rrsig_label_count(&self) -> u8
Returns the number of labels for the RRSIG Labels field.
This is the actual number of labels without counting the root label or a possible initial asterisk label.