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]
pub fn root() -> &'static Self
[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"
.
pub fn split_from(bytes: &[u8]) -> Option<(&Label, &[u8])>
[src]
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
.
pub fn from_bytes(bytes: &[u8]) -> Option<&Label>
[src]
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]
pub fn len(&self) -> usize
[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.
pub fn is_empty(&self) -> bool
[src]
Returns whether the label is empty.
(A well-formed label never is.)
pub fn is_root(&self) -> bool
[src]
Returns whether this label is the root label.
impl Label
[src]
pub fn content(&self) -> LabelContent
[src]
Returns the label’s content.
pub fn as_str(&self) -> Option<&str>
[src]
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.
pub fn as_bytes(&self) -> &[u8]
[src]
Returns a bytes slice with the raw content of this label.
ⓘImportant traits for LabelIter<'a>pub fn iter(&self) -> LabelIter
[src]
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]
impl ToOwned for Label
[src]
type Owned = LabelBuf
fn to_owned(&self) -> Self::Owned
[src]
Creates owned data from borrowed data, usually by cloning. Read more
fn clone_into(&self, target: &mut Self::Owned)
[src]
🔬 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]
fn eq(&self, other: &Self) -> bool
[src]
Tests whether self
and other
are equal.
As per the RFC, normal labels are compared ignoring the case of ASCII letters.
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl<T: AsRef<Label>> PartialEq<T> for Label
[src]
fn eq(&self, other: &T) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl PartialEq<[u8]> for Label
[src]
fn eq(&self, other: &[u8]) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl Eq for Label
[src]
impl Hash for Label
[src]
fn hash<H: Hasher>(&self, state: &mut H)
[src]
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl<'a> IntoIterator for &'a Label
[src]
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?
fn into_iter(self) -> Self::IntoIter
[src]
Creates an iterator from a value. Read more
impl Display for Label
[src]
fn fmt(&self, f: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl Octal for Label
[src]
impl LowerHex for Label
[src]
impl UpperHex for Label
[src]
impl Binary for Label
[src]
impl Debug for Label
[src]
fn fmt(&self, f: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl<'a> From<&'a Label> for LabelBuf
[src]
impl Borrow<Label> for LabelBuf
[src]
impl AsRef<Label> for LabelBuf
[src]
impl<'a> From<&'a Label> for &'a DNameSlice
[src]
fn from(label: &'a Label) -> &'a DNameSlice
[src]
Performs the conversion.