Trait domain::base::name::ToDname

source ·
pub trait ToDname: ToLabelIter {
Show 13 methods // Provided methods fn to_dname<Octets>(&self) -> Result<Dname<Octets>, PushError> where Octets: FromBuilder, <Octets as FromBuilder>::Builder: EmptyBuilder { ... } fn to_canonical_dname<Octets>(&self) -> Result<Dname<Octets>, PushError> 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) -> Dname<Cow<'_, [u8]>> { ... } fn to_vec(&self) -> Dname<Vec<u8>> { ... } fn to_bytes(&self) -> Dname<Bytes> { ... } fn name_eq<N: ToDname + ?Sized>(&self, other: &N) -> bool { ... } fn name_cmp<N: ToDname + ?Sized>(&self, other: &N) -> Ordering { ... } fn composed_cmp<N: ToDname + ?Sized>(&self, other: &N) -> Ordering { ... } fn lowercase_composed_cmp<N: ToDname + ?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 Dname, ParsedDname, and Chain<L, R> where R is ToDname itself.

Provided Methods§

source

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

source

fn to_canonical_dname<Octets>(&self) -> Result<Dname<Octets>, PushError>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 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) -> Dname<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_dname.

source

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

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

source

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

Returns the domain name assembled into a bytes value.

source

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

source

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

Returns the composed name ordering.

source

fn lowercase_composed_cmp<N: ToDname + ?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.

Implementations on Foreign Types§

source§

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

Implementors§

source§

impl<L: ToRelativeDname, R: ToDname> ToDname for Chain<L, R>

source§

impl<Octets, R> ToDname for Chain<UncertainDname<Octets>, R>where Octets: AsRef<[u8]>, R: ToDname,

source§

impl<Octs: AsRef<[u8]> + ?Sized> ToDname for Dname<Octs>

source§

impl<Octs: AsRef<[u8]>> ToDname for ParsedDname<Octs>