pub trait ToName: ToLabelIter {
Show 15 methods
// Provided methods
fn try_to_name<Octets>(
&self,
) -> Result<Name<Octets>, BuilderAppendError<Octets>>
where Octets: FromBuilder,
<Octets as FromBuilder>::Builder: EmptyBuilder { ... }
fn to_name<Octets>(&self) -> Name<Octets>
where Octets: FromBuilder,
<Octets as FromBuilder>::Builder: OctetsBuilder<AppendError = Infallible> + EmptyBuilder { ... }
fn try_to_canonical_name<Octets>(
&self,
) -> Result<Name<Octets>, BuilderAppendError<Octets>>
where Octets: FromBuilder,
<Octets as FromBuilder>::Builder: EmptyBuilder { ... }
fn to_canonical_name<Octets>(&self) -> Name<Octets>
where Octets: FromBuilder,
<Octets as FromBuilder>::Builder: OctetsBuilder<AppendError = Infallible> + 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) -> Name<Cow<'_, [u8]>> { ... }
fn to_vec(&self) -> Name<Vec<u8>> { ... }
fn to_bytes(&self) -> Name<Bytes> { ... }
fn name_eq<N: ToName + ?Sized>(&self, other: &N) -> bool { ... }
fn name_cmp<N: ToName + ?Sized>(&self, other: &N) -> Ordering { ... }
fn composed_cmp<N: ToName + ?Sized>(&self, other: &N) -> Ordering { ... }
fn lowercase_composed_cmp<N: ToName + ?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 Name
,
ParsedName
, and Chain<L, R>
where R
is ToName
itself.
Provided Methods§
sourcefn try_to_name<Octets>(
&self,
) -> Result<Name<Octets>, BuilderAppendError<Octets>>
fn try_to_name<Octets>( &self, ) -> Result<Name<Octets>, BuilderAppendError<Octets>>
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 Name
. This will
work for any name but an optimized implementation can be provided for
some types of names.
sourcefn to_name<Octets>(&self) -> Name<Octets>where
Octets: FromBuilder,
<Octets as FromBuilder>::Builder: OctetsBuilder<AppendError = Infallible> + EmptyBuilder,
fn to_name<Octets>(&self) -> Name<Octets>where
Octets: FromBuilder,
<Octets as FromBuilder>::Builder: OctetsBuilder<AppendError = Infallible> + EmptyBuilder,
Converts the name into a single, uncompressed name.
This is the same as try_to_name
but for
builder types with an unrestricted buffer.
sourcefn try_to_canonical_name<Octets>(
&self,
) -> Result<Name<Octets>, BuilderAppendError<Octets>>
fn try_to_canonical_name<Octets>( &self, ) -> Result<Name<Octets>, BuilderAppendError<Octets>>
Converts the name into a single name in canonical form.
sourcefn to_canonical_name<Octets>(&self) -> Name<Octets>where
Octets: FromBuilder,
<Octets as FromBuilder>::Builder: OctetsBuilder<AppendError = Infallible> + EmptyBuilder,
fn to_canonical_name<Octets>(&self) -> Name<Octets>where
Octets: FromBuilder,
<Octets as FromBuilder>::Builder: OctetsBuilder<AppendError = Infallible> + EmptyBuilder,
Converts the name into a single name in canonical form.
This is the same as
try_to_canonical_name
but for
builder types with an unrestricted buffer.
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) -> Name<Cow<'_, [u8]>>
fn to_cow(&self) -> Name<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_name
.
sourcefn name_cmp<N: ToName + ?Sized>(&self, other: &N) -> Ordering
fn name_cmp<N: ToName + ?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 ToName
since a blanket implementation for all
pairs of ToName
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: ToName + ?Sized>(&self, other: &N) -> Ordering
fn composed_cmp<N: ToName + ?Sized>(&self, other: &N) -> Ordering
Returns the composed name ordering.
sourcefn lowercase_composed_cmp<N: ToName + ?Sized>(&self, other: &N) -> Ordering
fn lowercase_composed_cmp<N: ToName + ?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.