domain::base::name

Trait ToName

source
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§

source

fn try_to_name<Octets>( &self, ) -> Result<Name<Octets>, BuilderAppendError<Octets>>
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 Name. This will work for any name but an optimized implementation can be provided for some types of names.

source

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.

source

fn try_to_canonical_name<Octets>( &self, ) -> Result<Name<Octets>, BuilderAppendError<Octets>>
where Octets: FromBuilder, <Octets as FromBuilder>::Builder: EmptyBuilder,

Converts the name into a single name in canonical form.

source

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.

source

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.

source

fn compose<Target: OctetsBuilder + ?Sized>( &self, target: &mut Target, ) -> Result<(), Target::AppendError>

source

fn compose_canonical<Target: OctetsBuilder + ?Sized>( &self, target: &mut Target, ) -> Result<(), Target::AppendError>

source

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.

source

fn to_vec(&self) -> Name<Vec<u8>>

Returns the domain name assembled into a Vec<u8>.

source

fn to_bytes(&self) -> Name<Bytes>

Returns the domain name assembled into a bytes value.

source

fn name_eq<N: ToName + ?Sized>(&self, other: &N) -> bool

Tests whether self and other are equal.

This method can be used to implement PartialEq on types implementing ToName since a blanket implementation for all pairs of ToName is currently impossible.

Domain names are compared ignoring ASCII case.

source

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 ToNames 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.

source

fn composed_cmp<N: ToName + ?Sized>(&self, other: &N) -> Ordering

Returns the composed name ordering.

source

fn lowercase_composed_cmp<N: ToName + ?Sized>(&self, other: &N) -> Ordering

Returns the lowercase composed ordering.

source

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.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<'a, N: ToName + ?Sized + 'a> ToName for &'a N

Implementors§

source§

impl<L: ToRelativeName, R: ToName> ToName for Chain<L, R>

source§

impl<Octets, R> ToName for Chain<UncertainName<Octets>, R>
where Octets: AsRef<[u8]>, R: ToName,

source§

impl<Octs: AsRef<[u8]> + ?Sized> ToName for Name<Octs>

source§

impl<Octs: AsRef<[u8]>> ToName for ParsedName<Octs>