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

An uncompressed, relative domain name.

A relative domain name is one that doesn’t end with the root label. As the name suggests, it is relative to some other domain name. This type wraps a octets sequence containing such a relative name similarly to the way Dname wraps an absolute one. In fact, it behaves very similarly to Dname taking into account differences when slicing and dicing names.

RelativeDname guarantees that the name is at most 254 bytes long. As the length limit for a domain name is actually 255 bytes, this means that you can always safely turn a RelativeDname into a Dname by adding the root label (which is exactly one byte long).

Implementations

Creates a relative domain name from octets without checking.

Since the content of the octets sequence can be anything, really, this is an unsafe function.

Safety

The octets sequence passed via octets must contain a correctly encoded relative domain name. It must be at most 254 octets long. There must be no root labels anywhere in the name.

Creates a relative domain name from an octets sequence.

This checks that octets contains a properly encoded relative domain name and fails if it doesn’t.

Creates an empty relative domain name.

Creates a relative domain name representing the wildcard label.

The wildcard label is intended to match any label. There are special rules for names with wildcard labels. Note that the comparison traits implemented for domain names do not consider wildcards and treat them as regular labels.

Creates a relative domain name from an octet slice.

Returns an empty relative name atop a unsized slice.

Creates an empty relative name atop a slice reference.

Creates a wildcard relative name atop a slice reference.

Creates an empty relative name atop a Vec<u8>.

Creates a wildcard relative name atop a Vec<u8>.

Creates an empty relative name atop a bytes value.

Creates a wildcard relative name atop a bytes value.

Returns a reference to the underlying octets.

Converts the name into the underlying octets.

Returns a domain name using a reference to the octets.

Returns a reference to an octets slice with the content of the name.

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

Converts the name into a domain name builder for appending data.

This method is only available for octets sequences that have an associated octets builder such as Vec<u8> or Bytes.

Converts the name into an absolute name by appending the root label.

This manipulates the name itself and thus is only available for octets sequences that can be converted into an octets builer and back such as Vec<u8>.

Chains another name to the end of this name.

Depending on whether other is an absolute or relative domain name, the resulting name will behave like an absolute or relative name.

The method will fail if the combined length of the two names is greater than the size limit of 255. Note that in this case you will loose both self and other, so it might be worthwhile to check first.

Creates an absolute name by chaining the root label to it.

Returns an iterator over the labels of the domain name.

Returns the number of labels in the name.

Returns a reference to the first label if the name isn’t empty.

Returns a reference to the last label if the name isn’t empty.

Returns the number of dots in the string representation of the name.

Specifically, returns a value equal to the number of labels minus one, except for an empty name where it returns a zero, also.

Determines whether base is a prefix of self.

Determines whether base is a suffix of self.

Returns whether an index points to the first octet of a label.

Returns a 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 beginning of a label or is out of bounds.

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 the position is not the beginning of a label or is beyond the end of the name.

Returns the part of the name ending before 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 the position is not the beginning of a label or is beyond the end of the name.

Returns a 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 beginning of a label or is out of bounds.

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 the position is not the beginning of a label or is beyond the end of the name.

Returns the part of the name ending before 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 the position is not the beginning of a label or is beyond the end of the name.

Splits the name into two at the given position.

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

Panics

The method panics if the position is not the beginning of a label or is beyond the end of the name.

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 panics if the position is not the beginning of a label or is beyond the end of the name.

Truncates the name to the given length.

Panics

The method panics if the position is not the beginning of a label or is beyond the end of the name.

Splits off the first label.

If there is at least one label in the name, returns the first label as a relative domain name with exactly one label and makes self contain the domain name starting after that first label. If the name is empty, returns None.

Reduces the name to its parent.

Returns whether that actually happened, since an empty name doesn’t have a parent.

Strips the suffix base from the domain name.

This will fail if base isn’t actually a suffix, i.e., if ends_with doesn’t return true.

Trait Implementations

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

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 value using the given formatter. Read more

Converts to this type from the input type.

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.

This method returns an Ordering between self and other. 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

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

Returns a byte slice of the content if possible. Read more

Returns whether the name is empty.

Converts the name into a single, continous name. Read more

Returns a cow of the relative 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

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.