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]
impl DNameSlice
pub unsafe fn from_bytes_unsafe(bytes: &[u8]) -> &DNameSlice
[src]
pub 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.
pub fn from_bytes(bytes: &[u8]) -> Option<&Self>
[src]
pub 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.
pub fn root() -> &'static DNameSlice
[src]
pub fn root() -> &'static DNameSlice
Creates a domain name slice for the root domain name.
pub fn empty() -> &'static DNameSlice
[src]
pub fn empty() -> &'static DNameSlice
Creates an empty domain name slice.
pub fn as_bytes(&self) -> &[u8]
[src]
pub fn as_bytes(&self) -> &[u8]
Returns a reference to the underlying bytes slice.
pub fn to_owned(&self) -> DNameBuf
[src]
pub fn to_owned(&self) -> DNameBuf
Converts the domain name slice to an owned domain name.
impl DNameSlice
[src]
impl DNameSlice
pub fn is_absolute(&self) -> bool
[src]
pub 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).
pub fn is_relative(&self) -> bool
[src]
pub fn is_relative(&self) -> bool
Checks whether the domain name is relative, ie., not absolute.
impl DNameSlice
[src]
impl DNameSlice
ⓘImportant traits for NameLabels<'a>pub fn labels(&self) -> NameLabels
[src]
pub fn labels(&self) -> NameLabels
Produces an iterator over the labels in the name.
ⓘImportant traits for NameLabelettes<'a>pub fn labelettes(&self) -> NameLabelettes
[src]
pub fn labelettes(&self) -> NameLabelettes
Produces an iterator over the labelettes in the name.
pub fn len(&self) -> usize
[src]
pub fn len(&self) -> usize
Returns the number of labels in self
.
pub fn is_empty(&self) -> bool
[src]
pub fn is_empty(&self) -> bool
Checks whether the domain name is empty.
pub fn first(&self) -> Option<&Label>
[src]
pub fn first(&self) -> Option<&Label>
Returns the first label or None
if the name is empty.
pub fn last(&self) -> Option<&Label>
[src]
pub fn last(&self) -> Option<&Label>
Returns the last label or None
if the name is empty.
pub fn ndots(&self) -> Option<usize>
[src]
pub 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]
impl DNameSlice
pub fn split_first(&self) -> Option<(&Label, &Self)>
[src]
pub 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).
pub fn parent(&self) -> Option<&DNameSlice>
[src]
pub 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.
pub fn strip_suffix<'a, N: DName>(
&'a self,
base: &'a N
) -> Result<Cow<'a, Self>, StripSuffixError>
[src]
pub fn strip_suffix<'a, N: DName>(
&'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]
pub fn starts_with<N: DName>(&self, base: &N) -> bool
Determines whether base
is a prefix of self
.
pub fn ends_with<N: DName>(&self, base: &N) -> bool
[src]
pub fn ends_with<N: DName>(&self, base: &N) -> bool
Determines whether base
is a suffix of self
.
pub fn join<N: DName>(&self, base: &N) -> Result<DNameBuf, PushError>
[src]
pub 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]
impl<'a> DName for &'a DNameSlice
fn to_cow(&self) -> Cow<DNameSlice>
[src]
fn to_cow(&self) -> Cow<DNameSlice>
Converts the name into an uncompressed name. Read more
ⓘImportant traits for NameLabels<'a>fn labels(&self) -> NameLabels
[src]
fn labels(&self) -> NameLabels
Returns an iterator over the labels of the domain name.
ⓘImportant traits for NameLabelettes<'a>fn labelettes(&self) -> NameLabelettes
[src]
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<()>
[src]
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<()>
[src]
fn compose_compressed<C: AsMut<Composer>>(
&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]
impl<'a> From<&'a Label> for &'a DNameSlice
fn from(label: &'a Label) -> &'a DNameSlice
[src]
fn from(label: &'a Label) -> &'a DNameSlice
Performs the conversion.
impl AsRef<DNameSlice> for DNameSlice
[src]
impl AsRef<DNameSlice> for DNameSlice
impl ToOwned for DNameSlice
[src]
impl ToOwned for DNameSlice
type Owned = DNameBuf
fn to_owned(&self) -> Self::Owned
[src]
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)
[src]
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]
impl<'a> IntoIterator for &'a DNameSlice
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]
fn into_iter(self) -> Self::IntoIter
Creates an iterator from a value. Read more
impl PartialEq for DNameSlice
[src]
impl PartialEq for DNameSlice
fn eq(&self, other: &Self) -> bool
[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[src]
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
impl<N: DName> PartialEq<N> for DNameSlice
[src]
impl<N: DName> PartialEq<N> for DNameSlice
fn eq(&self, other: &N) -> bool
[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[src]
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
impl PartialEq<str> for DNameSlice
[src]
impl PartialEq<str> for DNameSlice
fn eq(&self, other: &str) -> bool
[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[src]
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
impl Eq for DNameSlice
[src]
impl Eq for DNameSlice
impl PartialOrd for DNameSlice
[src]
impl PartialOrd for DNameSlice
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[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[src]
fn lt(&self, other: &Rhs) -> bool
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]
fn le(&self, other: &Rhs) -> bool
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]
fn gt(&self, other: &Rhs) -> bool
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]
fn ge(&self, other: &Rhs) -> bool
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]
impl<N: DName> PartialOrd<N> for DNameSlice
fn partial_cmp(&self, other: &N) -> Option<Ordering>
[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[src]
fn lt(&self, other: &Rhs) -> bool
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]
fn le(&self, other: &Rhs) -> bool
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]
fn gt(&self, other: &Rhs) -> bool
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]
fn ge(&self, other: &Rhs) -> bool
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]
impl Ord for DNameSlice
fn cmp(&self, other: &Self) -> Ordering
[src]
fn cmp(&self, other: &Self) -> Ordering
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
impl Hash for DNameSlice
[src]
impl Hash for DNameSlice
fn hash<H: Hasher>(&self, state: &mut H)
[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[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl Display for DNameSlice
[src]
impl Display for DNameSlice
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Octal for DNameSlice
[src]
impl Octal for DNameSlice
impl LowerHex for DNameSlice
[src]
impl LowerHex for DNameSlice
impl UpperHex for DNameSlice
[src]
impl UpperHex for DNameSlice
impl Binary for DNameSlice
[src]
impl Binary for DNameSlice
impl Debug for DNameSlice
[src]
impl Debug for DNameSlice
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<'a> From<&'a DNameSlice> for DNameBuf
[src]
impl<'a> From<&'a DNameSlice> for DNameBuf
fn from(name: &'a DNameSlice) -> DNameBuf
[src]
fn from(name: &'a DNameSlice) -> DNameBuf
Performs the conversion.
impl Borrow<DNameSlice> for DNameBuf
[src]
impl Borrow<DNameSlice> for DNameBuf
fn borrow(&self) -> &DNameSlice
[src]
fn borrow(&self) -> &DNameSlice
Immutably borrows from an owned value. Read more
impl AsRef<DNameSlice> for DNameBuf
[src]
impl AsRef<DNameSlice> for DNameBuf
fn as_ref(&self) -> &DNameSlice
[src]
fn as_ref(&self) -> &DNameSlice
Performs the conversion.
Auto Trait Implementations
impl Send for DNameSlice
impl Send for DNameSlice
impl Sync for DNameSlice
impl Sync for DNameSlice