Trait domain::base::name::ToRelativeName

source ·
pub trait ToRelativeName: ToLabelIter {
Show 15 methods // Provided methods fn try_to_relative_name<Octets>( &self, ) -> Result<RelativeName<Octets>, BuilderAppendError<Octets>> where Octets: FromBuilder, <Octets as FromBuilder>::Builder: EmptyBuilder { ... } fn to_relative_name<Octets>(&self) -> RelativeName<Octets> where Octets: FromBuilder, <Octets as FromBuilder>::Builder: OctetsBuilder<AppendError = Infallible> + EmptyBuilder { ... } fn try_to_canonical_relative_name<Octets>( &self, ) -> Result<RelativeName<Octets>, BuilderAppendError<Octets>> where Octets: FromBuilder, <Octets as FromBuilder>::Builder: EmptyBuilder { ... } fn to_canonical_relative_name<Octets>(&self) -> RelativeName<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) -> RelativeName<Cow<'_, [u8]>> { ... } fn to_vec(&self) -> RelativeName<Vec<u8>> { ... } fn to_bytes(&self) -> RelativeName<Bytes> { ... } fn is_empty(&self) -> bool { ... } fn chain<N: ToLabelIter>( self, suffix: N, ) -> Result<Chain<Self, N>, LongChainError> where Self: Sized { ... } fn chain_root(self) -> Chain<Self, Name<&'static [u8]>> where Self: Sized { ... } fn name_eq<N: ToRelativeName + ?Sized>(&self, other: &N) -> bool { ... } fn name_cmp<N: ToRelativeName + ?Sized>(&self, other: &N) -> Ordering { ... }
}
Expand description

A type that represents a relative domain name.

In order to be a relative domain name, a type needs to be able to provide a sequence of labels via an iterator where the last label is not the root label. The type also needs to be able to compose the wire-format representation of the domain name it represents which must not be longer than 254 characters. This limit has been chosen so that by attaching the one character long root label, a valid absolute name can be constructed from the relative name.

The most important types implementing this trait are RelativeName and Chain<L,R> where R is a ToRelativeName itself.

Provided Methods§

source

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

Converts the name into a single, continous name.

The canonical implementation provided by the trait iterates over the labels of the name and adds them one by one to RelativeName. This will work for any name but an optimized implementation can be provided for some types of names.

source

fn to_relative_name<Octets>(&self) -> RelativeName<Octets>
where Octets: FromBuilder, <Octets as FromBuilder>::Builder: OctetsBuilder<AppendError = Infallible> + EmptyBuilder,

Converts the name into a single, continous name.

This is the same as try_to_relative_name but for builder types with an unrestricted buffer.

source

fn try_to_canonical_relative_name<Octets>( &self, ) -> Result<RelativeName<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_relative_name<Octets>(&self) -> RelativeName<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_relative_name but for builder types with an unrestricted buffer.

source

fn as_flat_slice(&self) -> Option<&[u8]>

Returns a byte slice of the content if possible.

This method can 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) -> RelativeName<Cow<'_, [u8]>>

Returns a cow of the relative 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_relative_name.

source

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

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

source

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

Returns the domain name assembled into a bytes value.

source

fn is_empty(&self) -> bool

Returns whether the name is empty.

source

fn chain<N: ToLabelIter>( self, suffix: N, ) -> Result<Chain<Self, N>, LongChainError>
where Self: Sized,

Returns a chain of this name and the provided name.

source

fn chain_root(self) -> Chain<Self, Name<&'static [u8]>>
where Self: Sized,

Returns the absolute name by chaining it with the root label.

source

fn name_eq<N: ToRelativeName + ?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: ToRelativeName + ?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. This section describes how absolute domain names are ordered only. We will order relative domain names according to these rules as if they had the same origin, i.e., as if they were relative to the same name.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

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

Implementors§