pub struct Dname<Octets: ?Sized>(_);
Expand description

An uncompressed, absolute domain name.

The type wraps an octets sequence and guarantees that it always contains a correctly encoded, absolute domain name. It provides an interface similar to a slice of the labels of the name, i.e., you can iterate over the labels, split them off, etc.

You can construct a domain name from a string via the FromStr trait or manually via a DnameBuilder. In addition, you can also parse it from a message. This will, however, require the name to be uncompressed. Otherwise, you would receive a ParsedDname which can be converted into Dname via ToDname::to_dname.

Implementations

Creates a domain name from the underlying octets without any check.

Since this will allow to actually construct an incorrectly encoded domain name value, the function is unsafe.

Safety

The octets sequence passed in octets must contain a correctly encoded absolute domain name. It must be at most 255 octets long. It must contain the root label exactly once as its last label.

Creates a domain name from an octet sequence.

This will only succeed if octets contains a properly encoded absolute domain name. Because the function checks, this will take a wee bit of time.

Creates a domain name from a sequence of characters.

The sequence must result in a domain name in master format representation. That is, its labels should be separated by dots. Actual dots, white space and backslashes should be escaped by a preceeding backslash, and any byte value that is not a printable ASCII character should be encoded by a backslash followed by its three digit decimal value.

The name will always be an absolute name. If the last character in the sequence is not a dot, the function will quietly add a root label, anyway. In most cases, this is likely what you want. If it isn’t, though, use UncertainDname instead to be able to check.

Returns a domain name consisting of the root label only.

This function will work for any kind octets sequence that can be created from an octets slice. Since this will require providing the type parameter in some cases, there are shortcuts methods for specific octets types: root_ref, root_vec, and root_bytes.

Creates a domain name from an octets slice.

This will only succeed if slice contains a properly encoded absolute domain name.

Creates a domain name for the root label only atop an octets slice.

Creates a domain name for the root label only atop a slice reference.

Creates a domain name for the root label only atop a Vec<u8>.

Creates a domain name atop a Vec<u8> from its string representation.

Creates a domain name for the root label only atop a bytes values.

Creates a domain name atop a Bytes from its string representation.

Returns a reference to the underlying octets sequence.

Converts the domain name into the underlying octets sequence.

Converts the name into a relative name by dropping the root label.

Returns a domain name using a reference to the octets.

Returns a reference to the underlying octets slice.

Returns a domain name for the octets slice of the content.

Properties

More of the usual methods on octets sequences, such as len, are available via the implementation of Deref<Target = Octets>.

Returns whether the name is the root label only.

Working with Labels

All methods that split the name or cut off parts on the left side are only available on octets sequences that are their only range, e.g., &[u8] or Bytes, as these are the only types that can be split.

Returns an iterator over the labels of the domain 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.

Returns whether an index points to the first byte of a non-root label.

Returns the part of the name indicated by start and end positions.

The returned name will start at position begin and end right before position end. Both positions are given as indexes into the underlying octets sequence and must point to the begining of a label.

The method returns a reference to an unsized relative domain name and is thus best suited for temporary referencing. If you want to keep the part of the name around, range is likely a better choice.

Panics

The method panics if either position is not the start of a label or is out of bounds.

Because the returned domain name is relative, the method will also panic if the end is equal to the length of the name. If you want to slice the entire end of the name including the final root label, you can use slice_from() instead.

Returns the part of the name starting at the given position.

The returned name will start at the given postion and cover the remainder of the name. The position begin is provided as an index into the underlying octets sequence and must point to the beginning of a label.

The method returns a reference to an unsized domain name and is thus best suited for temporary referencing. If you want to keep the part of the name around, range_from is likely a better choice.

Panics

The method panics if begin isn’t the index of the beginning of a label or is out of bounds.

Returns the part of the name ending at the given position.

The returned name will start at beginning of the name and continue until just before the given postion. The position end is considered as an index into the underlying octets sequence and must point to the beginning of a label.

The method returns a reference to an unsized domain name and is thus best suited for temporary referencing. If you want to keep the part of the name around, range_to is likely a better choice.

Panics

The method panics if end is not the beginning of a label or is out of bounds. Because the returned domain name is relative, the method will also panic if the end is equal to the length of the name.

Returns the part of the name indicated by start and end positions.

The returned name will start at position begin and end right before position end. Both positions are given as indexes into the underlying octets sequence and must point to the begining of a label.

Panics

The method panics if either position is not the start of a label or is out of bounds.

Because the returned domain name is relative, the method will also panic if the end is equal to the length of the name. If you want to slice the entire end of the name including the final root label, you can use range_from() instead.

Returns the part of the name starting at the given position.

The returned name will start at the given postion and cover the remainder of the name. The position begin is provided as an index into the underlying octets sequence and must point to the beginning of a label.

Panics

The method panics if begin isn’t the index of the beginning of a label or is out of bounds.

Returns the part of the name ending at the given position.

The returned name will start at beginning of the name and continue until just before the given postion. The position end is considered as an index into the underlying octets sequence and must point to the beginning of a label.

Panics

The method panics if end is not the beginning of a label or is out of bounds. Because the returned domain name is relative, the method will also panic if the end is equal to the length of the name.

Splits the name into two at the given position.

Returns a pair of the left and right part of the split name.

Panics

The method will panic if mid is not the index of the beginning of a label or if it is out of bounds.

Splits the name into two at the given position.

Afterwards, self will contain the name starting at the position while the name ending right before it will be returned.

Panics

The method will panic if mid is not the start of a new label or is out of bounds.

Truncates the name before len.

Because truncating converts the name into a relative name, the method consumes self.

Panics

The method will panic if len is not the index of a new label or if it is out of bounds.

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.

Strips the suffix base from the domain name.

If base is indeed a suffix, returns a relative domain name with the remainder of the name. Otherwise, returns an error with an unmodified self.

Trait Implementations

Converts this type into a shared reference of the (usually inferred) input type.

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

The resulting type after dereferencing.

Dereferences the value.

Deserialize this value from the given Serde deserializer. 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.

Converts to this type from the input type.

Converts to this type from the input type.

Parses a string into an absolute domain name.

The implementation assumes that the string refers to an absolute name whether it ends in a dot or not. If you need to be able to distinguish between those two cases, you can use UncertainDname instead.

The associated error which can be returned from parsing.

Feeds this value 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

Performs the conversion.

Returns the ordering between self and other.

Domain name order is determined according to the ‘canonical DNS name order’ as defined in section 6.1 of RFC 4034.

Extracts a value from the beginning of parser. Read more

Skips over a value of this type at 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

Returns the ordering between self and other.

Domain name order is determined according to the ‘canonical DNS name order’ as defined in section 6.1 of RFC 4034.

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

Available on crate feature master only.

Scans a value from a master file.

Serialize this value into the given Serde serializer. 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.

Available on crate feature tsig only.

The representation of the key returned by the store.

Available on crate feature tsig only.

Tries to find a key in the store. Read more

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.