pub trait ToRelativeDname: Compose + for<'a> ToLabelIter<'a> {
// Provided methods
fn to_name(&self) -> RelativeDname { ... }
fn as_flat_slice(&self) -> Option<&[u8]> { ... }
fn chain<N: Compose>(
self,
suffix: N,
) -> Result<Chain<Self, N>, LongChainError>
where Self: Sized { ... }
fn chain_root(self) -> Chain<Self, Dname>
where Self: Sized { ... }
fn name_eq<N: ToRelativeDname>(&self, other: &N) -> bool { ... }
fn name_cmp<N: ToRelativeDname>(&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§
Sourcefn to_name(&self) -> RelativeDname
fn to_name(&self) -> RelativeDname
Creates an uncompressed value of the domain name.
The method has a default implementation that composes the name into
a new buffer and returns this buffer. If the implementing type can
create a RelativeDname more efficiently, then it should provide its
own implementation.
Sourcefn as_flat_slice(&self) -> Option<&[u8]>
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.
Sourcefn chain<N: Compose>(self, suffix: N) -> Result<Chain<Self, N>, LongChainError>where
Self: Sized,
fn chain<N: Compose>(self, suffix: N) -> Result<Chain<Self, N>, LongChainError>where
Self: Sized,
Returns a chain of this name and the provided absolute name.
Sourcefn chain_root(self) -> Chain<Self, Dname>where
Self: Sized,
fn chain_root(self) -> Chain<Self, Dname>where
Self: Sized,
Returns the absolute name by chaining it with the root label.
Sourcefn name_eq<N: ToRelativeDname>(&self, other: &N) -> bool
fn name_eq<N: ToRelativeDname>(&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: ToRelativeDname>(&self, other: &N) -> Ordering
fn name_cmp<N: ToRelativeDname>(&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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.