Trait domain::base::name::ToRelativeDname

source ·
pub trait ToRelativeDname: ToLabelIter {
Show 13 methods // Provided methods fn to_relative_dname<Octets>( &self, ) -> Result<RelativeDname<Octets>, BuilderAppendError<Octets>> where Octets: FromBuilder, <Octets as FromBuilder>::Builder: EmptyBuilder { ... } fn to_canonical_relative_dname<Octets>( &self, ) -> Result<RelativeDname<Octets>, BuilderAppendError<Octets>> 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) -> RelativeDname<Cow<'_, [u8]>> { ... } fn to_vec(&self) -> RelativeDname<Vec<u8>> { ... } fn to_bytes(&self) -> RelativeDname<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, Dname<&'static [u8]>> where Self: Sized { ... } fn name_eq<N: ToRelativeDname + ?Sized>(&self, other: &N) -> bool { ... } fn name_cmp<N: ToRelativeDname + ?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 RelativeDname and Chain<L,R> where R is a ToRelativeDname itself.

Provided Methods§

source

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

source

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

Converts the name into a single name in canonical form.

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) -> RelativeDname<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_dname.

source

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

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

source

fn to_bytes(&self) -> RelativeDname<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, Dname<&'static [u8]>>
where Self: Sized,

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

source

fn name_eq<N: ToRelativeDname + ?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.

source

fn name_cmp<N: ToRelativeDname + ?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 ToDnames 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: ToRelativeDname + ?Sized + 'a> ToRelativeDname for &'a N

Implementors§