Struct domain::bits::name::Label[][src]

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.

Methods

impl Label
[src]

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.

impl Label
[src]

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.

impl Label
[src]

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.

Important traits for LabelIter<'a>

Returns an iterator over the labelettes in this label.

See ['Labelette'] for what labelettes are supposed to be.

Trait Implementations

impl AsRef<Label> for Label
[src]

Performs the conversion.

impl ToOwned for Label
[src]

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

impl PartialEq for Label
[src]

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 !=.

impl<T: AsRef<Label>> PartialEq<T> for Label
[src]

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

This method tests for !=.

impl PartialEq<[u8]> for Label
[src]

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

This method tests for !=.

impl Eq for Label
[src]

impl Hash for Label
[src]

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

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

impl<'a> IntoIterator for &'a Label
[src]

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

impl Display for Label
[src]

Formats the value using the given formatter. Read more

impl Octal for Label
[src]

Formats the value using the given formatter.

impl LowerHex for Label
[src]

Formats the value using the given formatter.

impl UpperHex for Label
[src]

Formats the value using the given formatter.

impl Binary for Label
[src]

Formats the value using the given formatter.

impl Debug for Label
[src]

Formats the value using the given formatter. Read more

impl<'a> From<&'a Label> for LabelBuf
[src]

Performs the conversion.

impl Borrow<Label> for LabelBuf
[src]

Immutably borrows from an owned value. Read more

impl AsRef<Label> for LabelBuf
[src]

Performs the conversion.

impl<'a> From<&'a Label> for &'a DNameSlice
[src]

Performs the conversion.

impl<'a> From<&'a Label> for DNameBuf
[src]

Performs the conversion.

Auto Trait Implementations

impl Send for Label

impl Sync for Label