Struct domain::bits::name::DNameBuf [−][src]
pub struct DNameBuf { /* fields omitted */ }
An owned complete domain name.
A value of this type contains a vector with a correctly encoded,
uncompressed domain name. It derefs to DNameSlice
in order to make
all its methods available for working with domain names.
In addition, it provides a number of methods to add labels or entire names to its end.
DNameBuf
values can be created from string via the std::str::FromStr
trait. Such strings must be in the usual zonefile encoding.
Methods
impl DNameBuf
[src]
impl DNameBuf
pub fn new() -> Self
[src]
pub fn new() -> Self
Creates a new empty domain name.
pub fn with_capacity(capacity: usize) -> DNameBuf
[src]
pub fn with_capacity(capacity: usize) -> DNameBuf
Creates a new empty name with the given amount of space reserved.
pub fn from_vec(vec: Vec<u8>) -> Option<Self>
[src]
pub fn from_vec(vec: Vec<u8>) -> Option<Self>
Creates an owned domain name using an existing bytes vector.
If the content of the bytes vector does not constitute a correctly encoded uncompressed domain name, the function will fail.
pub fn try_from_iter<'a, T>(iter: T) -> Result<Self, PushError> where
T: IntoIterator<Item = &'a Label>,
[src]
pub fn try_from_iter<'a, T>(iter: T) -> Result<Self, PushError> where
T: IntoIterator<Item = &'a Label>,
Creates an owned domain name from the labels of the iterator.
pub fn scan<S: Scanner>(
scanner: &mut S,
origin: Option<&DNameSlice>
) -> ScanResult<Self>
[src]
pub fn scan<S: Scanner>(
scanner: &mut S,
origin: Option<&DNameSlice>
) -> ScanResult<Self>
Creates an owned domain name by reading it from a scanner.
pub fn root() -> DNameBuf
[src]
pub fn root() -> DNameBuf
Returns a new owned domain name consisting only of the root label.
pub fn as_slice(&self) -> &DNameSlice
[src]
pub fn as_slice(&self) -> &DNameSlice
Returns a reference to a slice of the domain name.
pub fn into_vec(self) -> Vec<u8>
[src]
pub fn into_vec(self) -> Vec<u8>
Extracts the underlying vector from the name.
impl DNameBuf
[src]
impl DNameBuf
Manipulations
pub fn push(&mut self, label: &Label) -> Result<(), PushError>
[src]
pub fn push(&mut self, label: &Label) -> Result<(), PushError>
Extends a relative name with a label.
If the name is absolute, nothing happens.
pub fn push_normal(&mut self, content: &[u8]) -> Result<(), PushError>
[src]
pub fn push_normal(&mut self, content: &[u8]) -> Result<(), PushError>
Pushes a normal label to the end of a relative name.
If the name is absolute, nothing happens. If the resulting name would exceed the maximum allowd length of 255 octets, returns an error.
Panics
The method panics if content
is longer that 63 bytes.
pub fn push_binary(
&mut self,
count: usize,
bits: &[u8]
) -> Result<(), PushError>
[src]
pub fn push_binary(
&mut self,
count: usize,
bits: &[u8]
) -> Result<(), PushError>
Pushes a binary label to the end of a relative name.
The binary label will be count
bits long and contain the bits
from bits
. If bits
is too short, the label will be filled up
with zero bits. If bits
is too long, it will be trimmed to the
right length.
If the name is absolute, nothing happens. If the resulting name would exceed the maximum allowd length of 255 octets, returns an error.
Panics
The method panics if count
is larger than 256.
pub fn push_empty_binary(
&mut self,
count: usize
) -> Result<Option<&mut [u8]>, PushError>
[src]
pub fn push_empty_binary(
&mut self,
count: usize
) -> Result<Option<&mut [u8]>, PushError>
Pushes an empty binary label of the given length to the domain name.
Upon success the function returns a mutable reference to the bytes slice of the bits of the binary label.
If the name is already absolute, returns Ok(None)
. If the resulting
name would exceed the maximum allowd length of 255 octets, returns an
error.
Panics
The method panics if count
is larger than 256.
pub fn append<N: DName>(&mut self, name: &N) -> Result<(), PushError>
[src]
pub fn append<N: DName>(&mut self, name: &N) -> Result<(), PushError>
Extends a relative name with a domain name.
If the name is already absolute, nothing will be appended and the name remains unchanged. If by appending the name would exceed the maximum allowed length of 255 octets, an error will be returned and the name remains unchanged, too.
pub fn append_root(&mut self) -> Result<(), PushError>
[src]
pub fn append_root(&mut self) -> Result<(), PushError>
Makes a domain name absolute if it isn’t yet by appending root.
This may fail if the name is already 255 octets long.
pub fn append_iter<'a, T>(&mut self, iter: T) -> Result<(), PushError> where
T: IntoIterator<Item = &'a Label>,
[src]
pub fn append_iter<'a, T>(&mut self, iter: T) -> Result<(), PushError> where
T: IntoIterator<Item = &'a Label>,
Appends the content of an iterator to the end of the name.
pub fn remove_first(&mut self)
[src]
pub fn remove_first(&mut self)
Removes the first label.
After this operation, the content of self
is self.parent()
.
Panics
Panics if the name is empty.
Methods from Deref<Target = DNameSlice>
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.
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.
ⓘ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.
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 Clone for DNameBuf
[src]
impl Clone for DNameBuf
fn clone(&self) -> DNameBuf
[src]
fn clone(&self) -> DNameBuf
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Default for DNameBuf
[src]
impl Default for DNameBuf
impl DName for DNameBuf
[src]
impl DName for DNameBuf
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> DName for &'a DNameBuf
[src]
impl<'a> DName for &'a DNameBuf
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 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<'a> From<&'a Label> for DNameBuf
[src]
impl<'a> From<&'a Label> for DNameBuf
impl FromStr for DNameBuf
[src]
impl FromStr for DNameBuf
type Err = FromStrError
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Self, Self::Err>
[src]
fn from_str(s: &str) -> Result<Self, Self::Err>
Creates a new domain name from a string.
The string must follow zone file conventions. It must only contain
printable ASCII characters and no whitespace. Invidual labels are
separated by a dot. A backslash escapes the next character unless
that is a 0
, 1
, or 2
, in which case the next three characters
are the byte value in decimal representation.
impl Deref for DNameBuf
[src]
impl Deref for DNameBuf
type Target = DNameSlice
The resulting type after dereferencing.
fn deref(&self) -> &Self::Target
[src]
fn deref(&self) -> &Self::Target
Dereferences the value.
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.
impl<N: DName> PartialEq<N> for DNameBuf
[src]
impl<N: DName> PartialEq<N> for DNameBuf
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 DNameBuf
[src]
impl PartialEq<str> for DNameBuf
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 DNameBuf
[src]
impl Eq for DNameBuf
impl<N: DName> PartialOrd<N> for DNameBuf
[src]
impl<N: DName> PartialOrd<N> for DNameBuf
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 DNameBuf
[src]
impl Ord for DNameBuf
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 DNameBuf
[src]
impl Hash for DNameBuf
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 DNameBuf
[src]
impl Display for DNameBuf
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 DNameBuf
[src]
impl Octal for DNameBuf
impl LowerHex for DNameBuf
[src]
impl LowerHex for DNameBuf
impl UpperHex for DNameBuf
[src]
impl UpperHex for DNameBuf
impl Binary for DNameBuf
[src]
impl Binary for DNameBuf
impl Debug for DNameBuf
[src]
impl Debug for DNameBuf