pub struct ParsedDname<Ref> { /* private fields */ }
Expand description

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 repeatedly appearing 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 remainder 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 name. Many operations can be performed by just iterating over the labels which we can do in place.

ParsedDname deals with such names. It takes a copy of a Parser representing a reference to the underlying DNS message and, if nedded, traverses over the name starting at the current position of the parser. When being created, the type quickly walks over the name to check that it is, indeed, a valid name. While this does take a bit of time, it spares you having to deal with possible parse errors later on.

ParsedDname implementes the ToDname trait, so you can use it everywhere where a generic absolute domain name is accepted. In particular, you can compare it to other names or chain it to the end of a relative name. If necessary, ToDname::to_name can be used to produce a flat, self-contained Dname.

Implementations

Returns whether the name is compressed.

Returns whether the name is the root label only.

Returns an iterator over the labels of the name.

Returns an iterator over the suffixes of the name.

The returned iterator starts with the full name and then for each additional step returns a name with the left-most label stripped off until it reaches the root label.

Returns the number of labels in the domain name.

Returns a reference to the first label.

Returns a reference to the last label.

Because the last label in an absolute name is always the root label, this method can return a static reference. It is also a wee bit silly, but here for completeness.

Determines whether base is a prefix of self.

Determines whether base is a suffix of self.

Splits off the first label.

If this name is longer than just the root label, returns the first label as a relative name and removes it from the name itself. If the name is only the root label, returns None and does nothing.

Reduces the name to the parent of the current name.

If the name consists of the root label only, returns false and does nothing. Otherwise, drops the first label and returns true.

Flatten ParsedDname into a Dname in case it is compressed, otherwise cheap copy the underlying octets.

Trait Implementations

Returns the canonical ordering between self and other.
Returns whether self is canonically less than other.
Returns whether self is canonically less than or equal to other.
Returns whether self is canonically greater than other.
Returns whether self is canonically greater than or equal to other.
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Appends the concrete representation of the value to the target. Read more
Appends the canonical representation of the value to the target. Read more
Formats the value using the given formatter. Read more

Formats the domain name.

This will produce the domain name in common display format without the trailing dot.

Converts to this type from the input type.
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
The type of the elements being iterated over.
Which kind of iterator are we turning this into?
Creates an iterator from a value. Read more
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
Restrict a value to a certain interval. Read more

Skip over a domain name.

This will only check the uncompressed part of the name. If the name is compressed but the compression pointer is invalid or the name pointed to is invalid or too long, the function will still succeed.

If you need to check that the name you are skipping over is valid, you will have to use parse and drop the result.

Extracts a value from the beginning of parser. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
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
Returns an octets slice of the content if possible. Read more
Converts the name into a single, uncompressed name. Read more
Returns a cow of the domain name. Read more
Returns the domain name assembled into a Vec<u8>.
Returns the domain name assembled into a bytes value.
Tests whether self and other are equal. Read more
Returns the ordering between self and other. Read more
Returns the composed name ordering.
Returns the lowercase composed ordering.
Returns the number of labels for the RRSIG Labels field. Read more
The type of the iterator over the labels. Read more
Returns an iterator over the labels.
Returns the length in octets of the encoded name.
Determines whether base is a prefix of self.
Determines whether base is a suffix of self.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Performs the conversion.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.