Struct domain::bits::DNameSlice
[−]
[src]
pub struct DNameSlice { /* fields omitted */ }
A slice of a domain name.
The slice is guaranteed to contain a correctly encoded domain name. The name may be relative or absolute but cannot support name compression.
Operations are available for iterating over the labels of the name and breaking the name up into parts along the lines of label boundaries.
This is an unsized type. You will have to use it with some kind of
pointer, such as a reference or box. The sibling type owning the name
outright is DNameBuf
. The two can be used together through the
AsRef<DNameSlice>
trait or via a Cow<DNameSlice>
.
Methods
impl DNameSlice
[src]
pub unsafe fn from_bytes_unsafe(bytes: &[u8]) -> &DNameSlice
[src]
Creates a domain name slice from a bytes slice without checking.
This is only safe if the input slice follows the encoding rules for a domain name and does not contain compressed labels.
pub fn from_bytes(bytes: &[u8]) -> Option<&Self>
[src]
Creates a domain name from a bytes slice if it contains a valid name.
The bytes slice must be exactly one correctly encoded, uncompressed
domain name. If it isn’t or if it contains trailing data, the
function returns None
.
As this function traverses the slice to check that it is correctly encoded, it may take a bit of time.
pub fn root() -> &'static DNameSlice
[src]
Creates a domain name slice for the root domain name.
pub fn empty() -> &'static DNameSlice
[src]
Creates an empty domain name slice.
pub fn as_bytes(&self) -> &[u8]
[src]
Returns a reference to the underlying bytes slice.
pub fn to_owned(&self) -> DNameBuf
[src]
Converts the domain name slice to an owned domain name.
impl DNameSlice
[src]
pub fn is_absolute(&self) -> bool
[src]
Checks whether the domain name is absolute.
A domain name is absolute if it ends with an empty normal label (the root label).
pub fn is_relative(&self) -> bool
[src]
Checks whether the domain name is relative, ie., not absolute.
impl DNameSlice
[src]
ⓘImportant traits for NameLabels<'a>pub fn labels(&self) -> NameLabels
[src]
Produces an iterator over the labels in the name.
ⓘImportant traits for NameLabelettes<'a>pub fn labelettes(&self) -> NameLabelettes
[src]
Produces an iterator over the labelettes in the name.
pub fn len(&self) -> usize
[src]
Returns the number of labels in self
.
pub fn is_empty(&self) -> bool
[src]
Checks whether the domain name is empty.
pub fn first(&self) -> Option<&Label>
[src]
Returns the first label or None
if the name is empty.
pub fn last(&self) -> Option<&Label>
[src]
Returns the last label or None
if the name is empty.
pub fn ndots(&self) -> Option<usize>
[src]
Returns the number of dots if this is a relative name.
Returns None
if this is an absolute name.
impl DNameSlice
[src]
pub fn split_first(&self) -> Option<(&Label, &Self)>
[src]
Returns the first label and the remaining domain name.
Returns None
only if the name is empty (which is different from a
name containing only the root label).
pub fn parent(&self) -> Option<&DNameSlice>
[src]
Returns the domain name without its leftmost label.
Returns None
for an empty domain name and a domain name consisting
of only the root label. Returns an empty domain name for a single
label relative domain name.
pub fn strip_suffix<'a, N: DName>(
&'a self,
base: &'a N
) -> Result<Cow<'a, Self>, StripSuffixError>
[src]
&'a self,
base: &'a N
) -> Result<Cow<'a, Self>, StripSuffixError>
Returns a domain name slice relative to base
.
This fails if base
isn’t a suffix of self
.
pub fn starts_with<N: DName>(&self, base: &N) -> bool
[src]
Determines whether base
is a prefix of self
.
pub fn ends_with<N: DName>(&self, base: &N) -> bool
[src]
Determines whether base
is a suffix of self
.
pub fn join<N: DName>(&self, base: &N) -> Result<DNameBuf, PushError>
[src]
Creates an owned domain name made absolute if necessary.
If self
is already an absolute domain name, nothing happens.
Trait Implementations
impl<'a> DName for &'a DNameSlice
[src]
fn to_cow(&self) -> Cow<DNameSlice>
[src]
Converts the name into an uncompressed name. Read more
ⓘImportant traits for NameLabels<'a>fn labels(&self) -> NameLabels
[src]
Returns an iterator over the labels of the domain name.
ⓘImportant traits for NameLabelettes<'a>fn labelettes(&self) -> NameLabelettes
[src]
Returns an iterator over the labelettes of the domain name. Read more
fn compose<C: AsMut<Composer>>(&self, composer: C) -> ComposeResult<()>
[src]
Appends the name to the end of a composition.
fn compose_compressed<C: AsMut<Composer>>(
&self,
composer: C
) -> ComposeResult<()>
[src]
&self,
composer: C
) -> ComposeResult<()>
Appends the name to the end of a composition using name compression.
impl<'a> From<&'a Label> for &'a DNameSlice
[src]
fn from(label: &'a Label) -> &'a DNameSlice
[src]
Performs the conversion.
impl AsRef<DNameSlice> for DNameSlice
[src]
impl ToOwned for DNameSlice
[src]
type Owned = DNameBuf
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<'a> IntoIterator for &'a DNameSlice
[src]
type Item = &'a Label
The type of the elements being iterated over.
type IntoIter = NameLabels<'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 PartialEq for DNameSlice
[src]
fn eq(&self, other: &Self) -> 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<N: DName> PartialEq<N> for DNameSlice
[src]
fn eq(&self, other: &N) -> 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<str> for DNameSlice
[src]
fn eq(&self, other: &str) -> 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 DNameSlice
[src]
impl PartialOrd for DNameSlice
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl<N: DName> PartialOrd<N> for DNameSlice
[src]
fn partial_cmp(&self, other: &N) -> Option<Ordering>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Ord for DNameSlice
[src]
fn cmp(&self, other: &Self) -> Ordering
[src]
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
Compares and returns the minimum of two values. Read more
impl Hash for DNameSlice
[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 Display for DNameSlice
[src]
fn fmt(&self, f: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl Octal for DNameSlice
[src]
impl LowerHex for DNameSlice
[src]
impl UpperHex for DNameSlice
[src]
impl Binary for DNameSlice
[src]
impl Debug for DNameSlice
[src]
fn fmt(&self, f: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl<'a> From<&'a DNameSlice> for DNameBuf
[src]
fn from(name: &'a DNameSlice) -> DNameBuf
[src]
Performs the conversion.
impl Borrow<DNameSlice> for DNameBuf
[src]
fn borrow(&self) -> &DNameSlice
[src]
Immutably borrows from an owned value. Read more
impl AsRef<DNameSlice> for DNameBuf
[src]
fn as_ref(&self) -> &DNameSlice
[src]
Performs the conversion.