Struct domain::bits::ParsedDName[][src]

pub struct ParsedDName<'a> { /* fields omitted */ }

A domain name parsed from a DNS message.

In an attempt to keep messages small, DNS uses a procedure called name compression. It tries to minimize the space used for repeated domain names by simply refering to the first occurence of the name. This works not only for complete names but also for suffixes. In this case, the first unique labels of the name are included and then a pointer is included for the rest of the name.

A consequence of this is that when parsing a domain name, its labels can be scattered all over the message and we would need to allocate some space to re-assemble the original name. However, in many cases we don’t need the complete message. Many operations can be completed by just iterating over the labels which we can do in place.

This is what the ParsedDName type does: It takes a reference to a message and an indicator where inside the message the name starts and then walks over the message as necessity dictates. When created while parsing a message, the parser quickly walks over the labels to make sure that the name indeed is valid. While this takes up a bit of time, it avoids late surprises and provides for a nicer interface with less Results.

Obviously, ParsedDName implements the DName trait and provides all operations required by this trait. It also implements PartialEq and Eq, as well as PartialOrd and Ord against all other domain name types, plus Hash with the same as the other types.

Methods

impl<'a> ParsedDName<'a>
[src]

Creates a new parsed domain name.

This parses out the leading uncompressed labels from the parser and then quickly jumps over any possible remaining compressing to check that the name is valid.

Unpacks the name.

This will return the cow’s borrowed variant for any parsed name that isn’t in fact compressed. Otherwise it will assemble all the labels into an owned domain name.

Returns a slice if the name is uncompressed.

impl<'a> ParsedDName<'a>
[src]

Important traits for NameLabels<'a>

Returns an iterator over the labels of the name.

Important traits for NameLabelettes<'a>

Returns an iterator over the labelettes of the name.

Splits off the first label from the name.

For correctly encoded names, this function will always return Some(_). The first element will be the parsed out label. The second element will be a parsed name of the remainder of the name if the label wasn’t the root label or None otherwise.

Trait Implementations

impl<'a> Clone for ParsedDName<'a>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<'a> DName for ParsedDName<'a>
[src]

Converts the name into an uncompressed name. Read more

Important traits for NameLabels<'a>

Returns an iterator over the labels of the domain name.

Important traits for NameLabelettes<'a>

Returns an iterator over the labelettes of the domain name. Read more

Appends the name to the end of a composition.

Appends the name to the end of a composition using name compression.

impl<'a, N: DName> PartialEq<N> for ParsedDName<'a>
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl<'a> PartialEq<str> for ParsedDName<'a>
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl<'a> Eq for ParsedDName<'a>
[src]

impl<'a, N: DName> PartialOrd<N> for ParsedDName<'a>
[src]

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl<'a> Ord for ParsedDName<'a>
[src]

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

impl<'a> Hash for ParsedDName<'a>
[src]

Feeds this value into the given [Hasher]. Read more

Feeds a slice of this type into the given [Hasher]. Read more

impl<'a> Display for ParsedDName<'a>
[src]

Formats the value using the given formatter. Read more

impl<'a> Octal for ParsedDName<'a>
[src]

Formats the value using the given formatter.

impl<'a> LowerHex for ParsedDName<'a>
[src]

Formats the value using the given formatter.

impl<'a> UpperHex for ParsedDName<'a>
[src]

Formats the value using the given formatter.

impl<'a> Binary for ParsedDName<'a>
[src]

Formats the value using the given formatter.

impl<'a> Debug for ParsedDName<'a>
[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl<'a> Send for ParsedDName<'a>

impl<'a> Sync for ParsedDName<'a>