Struct domain::bits::name::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]
unsafe fn from_bytes_unsafe(bytes: &[u8]) -> &DNameSlice
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.
fn from_bytes(bytes: &[u8]) -> Option<&Self>
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.
fn root() -> &'static DNameSlice
Creates a domain name slice for the root domain name.
fn empty() -> &'static DNameSlice
Creates an empty domain name slice.
fn as_bytes(&self) -> &[u8]
Returns a reference to the underlying bytes slice.
fn to_owned(&self) -> DNameBuf
Converts the domain name slice to an owned domain name.
impl DNameSlice
[src]
fn is_absolute(&self) -> bool
Checks whether the domain name is absolute.
A domain name is absolute if it ends with an empty normal label (the root label).
fn is_relative(&self) -> bool
Checks whether the domain name is relative, ie., not absolute.
impl DNameSlice
[src]
fn labels(&self) -> NameLabels
Produces an iterator over the labels in the name.
fn labelettes(&self) -> NameLabelettes
Produces an iterator over the labelettes in the name.
fn len(&self) -> usize
Returns the number of labels in self
.
fn is_empty(&self) -> bool
Checks whether the domain name is empty.
fn first(&self) -> Option<&Label>
Returns the first label or None
if the name is empty.
fn last(&self) -> Option<&Label>
Returns the last label or None
if the name is empty.
fn ndots(&self) -> Option<usize>
Returns the number of dots if this is a relative name.
Returns None
if this is an absolute name.
impl DNameSlice
[src]
fn split_first(&self) -> Option<(&Label, &Self)>
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).
fn parent(&self) -> Option<&DNameSlice>
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.
fn strip_suffix<'a, N: DName>(
&'a self,
base: &'a N
) -> Result<Cow<'a, Self>, StripSuffixError>
&'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
.
fn starts_with<N: DName>(&self, base: &N) -> bool
Determines whether base
is a prefix of self
.
fn ends_with<N: DName>(&self, base: &N) -> bool
Determines whether base
is a suffix of self
.
fn join<N: DName>(&self, base: &N) -> Result<DNameBuf, PushError>
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>
Converts the name into an uncompressed name. Read more
fn labels(&self) -> NameLabels
Returns an iterator over the labels of the domain name.
fn labelettes(&self) -> NameLabelettes
Returns an iterator over the labelettes of the domain name. Read more
fn compose<C: AsMut<Composer>>(&self, composer: C) -> ComposeResult<()>
Appends the name to the end of a composition.
fn compose_compressed<C: AsMut<Composer>>(
&self,
composer: C
) -> ComposeResult<()>
&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
Performs the conversion.
impl AsRef<DNameSlice> for DNameSlice
[src]
fn as_ref(&self) -> &Self
Performs the conversion.
impl ToOwned for DNameSlice
[src]
type Owned = DNameBuf
fn to_owned(&self) -> Self::Owned
Creates owned data from borrowed data, usually by cloning. Read more
fn clone_into(&self, target: &mut Self::Owned)
🔬 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
Creates an iterator from a value. Read more
impl PartialEq for DNameSlice
[src]
fn eq(&self, other: &Self) -> bool
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
This method tests for !=
.
impl<N: DName> PartialEq<N> for DNameSlice
[src]
fn eq(&self, other: &N) -> bool
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
This method tests for !=
.
impl PartialEq<str> for DNameSlice
[src]
fn eq(&self, other: &str) -> bool
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
This method tests for !=
.
impl Eq for DNameSlice
[src]
impl PartialOrd for DNameSlice
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0
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
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
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
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>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0
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
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
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
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
This method returns an Ordering
between self
and other
. Read more
impl Hash for DNameSlice
[src]
fn hash<H: Hasher>(&self, state: &mut H)
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more