Enum domain::base::name::UncertainDname
source · pub enum UncertainDname<Octets> {
Absolute(Dname<Octets>),
Relative(RelativeDname<Octets>),
}
Expand description
A domain name that may be absolute or relative.
This type is helpful when reading a domain name from some source where it may end up being absolute or not.
Variants§
Absolute(Dname<Octets>)
Relative(RelativeDname<Octets>)
Implementations§
source§impl<Octets> UncertainDname<Octets>
impl<Octets> UncertainDname<Octets>
sourcepub fn absolute(name: Dname<Octets>) -> Self
pub fn absolute(name: Dname<Octets>) -> Self
Creates a new uncertain domain name from an absolute domain name.
sourcepub fn relative(name: RelativeDname<Octets>) -> Self
pub fn relative(name: RelativeDname<Octets>) -> Self
Creates a new uncertain domain name from a relative domain name.
sourcepub fn root() -> Selfwhere
Octets: From<&'static [u8]>,
pub fn root() -> Selfwhere Octets: From<&'static [u8]>,
Creates a new uncertain domain name containing the root label only.
sourcepub fn empty() -> Selfwhere
Octets: From<&'static [u8]>,
pub fn empty() -> Selfwhere Octets: From<&'static [u8]>,
Creates a new uncertain yet empty domain name.
sourcepub fn from_octets(octets: Octets) -> Result<Self, UncertainDnameError>where
Octets: AsRef<[u8]>,
pub fn from_octets(octets: Octets) -> Result<Self, UncertainDnameError>where Octets: AsRef<[u8]>,
Creates a new domain name from its wire format representation.
The returned name will correctly be identified as an absolute or relative name.
sourcepub fn from_chars<C>(chars: C) -> Result<Self, FromStrError>where
Octets: FromBuilder,
<Octets as FromBuilder>::Builder: FreezeBuilder<Octets = Octets> + EmptyBuilder + AsRef<[u8]> + AsMut<[u8]>,
C: IntoIterator<Item = char>,
pub fn from_chars<C>(chars: C) -> Result<Self, FromStrError>where Octets: FromBuilder, <Octets as FromBuilder>::Builder: FreezeBuilder<Octets = Octets> + EmptyBuilder + AsRef<[u8]> + AsMut<[u8]>, C: IntoIterator<Item = char>,
Creates a domain name from a sequence of characters.
The sequence must result in a domain name in zone file representation. That is, its labels should be separated by dots, while actual dots, white space and backslashes should be escaped by a preceeding backslash, and any byte value that is not a printable ASCII character should be encoded by a backslash followed by its three digit decimal value.
If Internationalized Domain Names are to be used, the labels already need to be in punycode-encoded form.
If the last character is a dot, the name will be absolute, otherwise it will be relative.
If you have a string, you can also use the FromStr
trait, which
really does the same thing.
pub fn scan<S: Scanner<Dname = Dname<Octets>>>( scanner: &mut S ) -> Result<Self, S::Error>
source§impl UncertainDname<&'static [u8]>
impl UncertainDname<&'static [u8]>
source§impl UncertainDname<Vec<u8>>
impl UncertainDname<Vec<u8>>
source§impl UncertainDname<Bytes>
impl UncertainDname<Bytes>
sourcepub fn empty_bytes() -> Self
pub fn empty_bytes() -> Self
Creates an empty relative name atop a bytes value.
sourcepub fn root_bytes() -> Self
pub fn root_bytes() -> Self
Creates an absolute name from the root label atop a bytes value.
source§impl<Octets> UncertainDname<Octets>
impl<Octets> UncertainDname<Octets>
sourcepub fn is_absolute(&self) -> bool
pub fn is_absolute(&self) -> bool
Returns whether the name is absolute.
sourcepub fn is_relative(&self) -> bool
pub fn is_relative(&self) -> bool
Returns whether the name is relative.
sourcepub fn as_absolute(&self) -> Option<&Dname<Octets>>
pub fn as_absolute(&self) -> Option<&Dname<Octets>>
Returns a reference to an absolute name, if this name is absolute.
sourcepub fn as_relative(&self) -> Option<&RelativeDname<Octets>>
pub fn as_relative(&self) -> Option<&RelativeDname<Octets>>
Returns a reference to a relative name, if the name is relative.
sourcepub fn into_absolute(self) -> Result<Dname<Octets>, PushError>where
Octets: AsRef<[u8]> + IntoBuilder,
<Octets as IntoBuilder>::Builder: FreezeBuilder<Octets = Octets> + AsRef<[u8]> + AsMut<[u8]>,
pub fn into_absolute(self) -> Result<Dname<Octets>, PushError>where Octets: AsRef<[u8]> + IntoBuilder, <Octets as IntoBuilder>::Builder: FreezeBuilder<Octets = Octets> + AsRef<[u8]> + AsMut<[u8]>,
Converts the name into an absolute name.
If the name is relative, appends the root label to it using
RelativeDname::into_absolute
.
sourcepub fn try_into_absolute(self) -> Result<Dname<Octets>, Self>
pub fn try_into_absolute(self) -> Result<Dname<Octets>, Self>
Converts the name into an absolute name if it is absolute.
Otherwise, returns itself as the error.
sourcepub fn try_into_relative(self) -> Result<RelativeDname<Octets>, Self>
pub fn try_into_relative(self) -> Result<RelativeDname<Octets>, Self>
Converts the name into a relative name if it is relative.
Otherwise just returns itself as the error.
sourcepub fn as_slice(&self) -> &[u8] ⓘwhere
Octets: AsRef<[u8]>,
pub fn as_slice(&self) -> &[u8] ⓘwhere Octets: AsRef<[u8]>,
Returns an octets slice with the raw content of the name.
sourcepub fn chain<S: ToLabelIter>(
self,
suffix: S
) -> Result<Chain<Self, S>, LongChainError>where
Octets: AsRef<[u8]>,
pub fn chain<S: ToLabelIter>( self, suffix: S ) -> Result<Chain<Self, S>, LongChainError>where Octets: AsRef<[u8]>,
Makes an uncertain name absolute by chaining on a suffix if needed.
The method converts the uncertain name into a chain that will
be absolute. If the name is already absolute, the chain will be the
name itself. If it is relative, if will be the concatenation of the
name and suffix
.
Trait Implementations§
source§impl<Octs> AsRef<Octs> for UncertainDname<Octs>
impl<Octs> AsRef<Octs> for UncertainDname<Octs>
source§impl<Octets: Clone> Clone for UncertainDname<Octets>
impl<Octets: Clone> Clone for UncertainDname<Octets>
source§fn clone(&self) -> UncertainDname<Octets>
fn clone(&self) -> UncertainDname<Octets>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<Octets> From<Dname<Octets>> for UncertainDname<Octets>
impl<Octets> From<Dname<Octets>> for UncertainDname<Octets>
source§impl<Octets> From<RelativeDname<Octets>> for UncertainDname<Octets>
impl<Octets> From<RelativeDname<Octets>> for UncertainDname<Octets>
source§fn from(src: RelativeDname<Octets>) -> Self
fn from(src: RelativeDname<Octets>) -> Self
source§impl<Octets> FromStr for UncertainDname<Octets>where
Octets: FromBuilder,
<Octets as FromBuilder>::Builder: EmptyBuilder + FreezeBuilder<Octets = Octets> + AsRef<[u8]> + AsMut<[u8]>,
impl<Octets> FromStr for UncertainDname<Octets>where Octets: FromBuilder, <Octets as FromBuilder>::Builder: EmptyBuilder + FreezeBuilder<Octets = Octets> + AsRef<[u8]> + AsMut<[u8]>,
source§impl<'a, Octets: AsRef<[u8]>> IntoIterator for &'a UncertainDname<Octets>
impl<'a, Octets: AsRef<[u8]>> IntoIterator for &'a UncertainDname<Octets>
source§impl<Octets, Other> PartialEq<UncertainDname<Other>> for UncertainDname<Octets>where
Octets: AsRef<[u8]>,
Other: AsRef<[u8]>,
impl<Octets, Other> PartialEq<UncertainDname<Other>> for UncertainDname<Octets>where Octets: AsRef<[u8]>, Other: AsRef<[u8]>,
source§fn eq(&self, other: &UncertainDname<Other>) -> bool
fn eq(&self, other: &UncertainDname<Other>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<Octs: AsRef<[u8]>> ToLabelIter for UncertainDname<Octs>
impl<Octs: AsRef<[u8]>> ToLabelIter for UncertainDname<Octs>
§type LabelIter<'a> = DnameIter<'a>
where
Octs: 'a
type LabelIter<'a> = DnameIter<'a> where Octs: 'a
source§fn iter_labels(&self) -> Self::LabelIter<'_>
fn iter_labels(&self) -> Self::LabelIter<'_>
source§fn compose_len(&self) -> u16
fn compose_len(&self) -> u16
source§fn starts_with<N: ToLabelIter + ?Sized>(&self, base: &N) -> bool
fn starts_with<N: ToLabelIter + ?Sized>(&self, base: &N) -> bool
base
is a prefix of self
.