pub struct Label { /* fields omitted */ }
An uncompressed domain name label.
This type wraps the bytes slice of a wire-encoded domain name label. It
is only used for labels with their own content, not for ‘pointer labels’
used with name compression.
There are two types of such labels: normal labels and binary labels.
Normal labels consist of up to 63 bytes of data. Binary labels are a
sequence of up to 256 one-bit labels. They have been invented for reverse
pointer records for IPv6 but have quickly been found to be rather
unwieldly and were never widely implemented. Subsequently they have been
declared historic and shouldn’t really be found in the wild.
There is room for even more label types, but since experience has shown
the introduction of new types to be difficult, their emergence is rather
unlikely.
The main purpose of the Label
type is to make implementing the other
domain name type more easy. It is unlikely that you will have to deal
with it too often. If at all, you can use it to get at its content via
the content()
method. This method returns a variant of the
LabelContent
enum. See its documentation for a discussion of the
formatting of the various label types.
Returns a reference to the root label.
The root label is an empty normal label. That is, it is the bytes
slice b"\0"
.
Splits a label from the beginning of a bytes slice.
If this succeeds, the functon returns a label and the remainder of
the slice. If it fails for whatever reason, be it because of
illegal values somewhere or because of a short bytes slice, the
function quietly returns None
.
Returns a label from a bytes slice.
Returns Some(_)
if the bytes slice contains a correctly encoded,
uncompressed label or None
otherwise. Also returns None
if the
label ends short of the entire slice.
Returns the length of the label.
This is equal to the length of the wire representation of the label.
For normal labels, it is one more than the length of the content.
For binary labels, things are a wee bit more complicated. See the
discussion of label encodings with the LabelContent
type for
more details.
Returns whether the label is empty.
(A well-formed label never is.)
Returns whether this label is the root label.
Returns the label’s content.
Returns a string slice if this is a normal label and purely ASCII.
To get a string representation of any label, you can use the
format!()
macro as Label
implements the Display
trait.
Returns a bytes slice with the raw content of this label.
Returns an iterator over the labelettes in this label.
See ['Labelette'] for what labelettes are supposed to be.
type Owned = LabelBuf
Creates owned data from borrowed data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
Tests whether self
and other
are equal.
As per the RFC, normal labels are compared ignoring the case of
ASCII letters.
This method tests for !=
.
This method tests for self
and other
values to be equal, and is used by ==
. Read more
This method tests for !=
.
This method tests for self
and other
values to be equal, and is used by ==
. Read more
This method tests for !=
.
Feeds this value into the given [Hasher
]. Read more
Feeds a slice of this type into the given [Hasher
]. Read more
type Item = Labelette<'a>
The type of the elements being iterated over.
type IntoIter = LabelIter<'a>
Which kind of iterator are we turning this into?
Formats the value using the given formatter. Read more
Formats the value using the given formatter.
Formats the value using the given formatter.
Formats the value using the given formatter.
Formats the value using the given formatter.
Formats the value using the given formatter. Read more
Immutably borrows from an owned value. Read more