pub enum UncertainDname {
Absolute(Dname),
Relative(RelativeDname),
}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)
Relative(RelativeDname)
Implementations§
Source§impl UncertainDname
impl UncertainDname
Sourcepub fn absolute(name: Dname) -> Self
pub fn absolute(name: Dname) -> Self
Creates a new uncertain domain name from an absolute domain name.
Sourcepub fn relative(name: RelativeDname) -> Self
pub fn relative(name: RelativeDname) -> Self
Creates a new uncertain domain name from a relative domain name.
Sourcepub fn from_chars<C>(chars: C) -> Result<Self, FromStrError>where
C: IntoIterator<Item = char>,
pub fn from_chars<C>(chars: C) -> Result<Self, FromStrError>where
C: IntoIterator<Item = char>,
Creates a domain name from a sequence of characters.
The sequence must result in a domain name in master format representation. That is, its labels should be separated by dots, 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 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.
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>
pub fn as_absolute(&self) -> Option<&Dname>
Returns a reference to an absolute name, if this name is absolute.
Sourcepub fn as_relative(&self) -> Option<&RelativeDname>
pub fn as_relative(&self) -> Option<&RelativeDname>
Returns a reference to a relative name, if the name is relative.
Sourcepub fn try_into_absolute(self) -> Result<Dname, Self>
pub fn try_into_absolute(self) -> Result<Dname, 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, Self>
pub fn try_into_relative(self) -> Result<RelativeDname, Self>
Converts the name into a relative name if it is relative.
Otherwise just returns itself as the error.
Sourcepub fn into_absolute(self) -> Dname
pub fn into_absolute(self) -> Dname
Converts the name into an absolute name.
If the name is relative, appends the root label to it using
RelativeDname::into_absolute.
Sourcepub fn chain<S: ToDname>(
self,
suffix: S,
) -> Result<Chain<Self, S>, LongChainError>
pub fn chain<S: ToDname>( self, suffix: S, ) -> Result<Chain<Self, S>, LongChainError>
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 Clone for UncertainDname
impl Clone for UncertainDname
Source§fn clone(&self) -> UncertainDname
fn clone(&self) -> UncertainDname
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Compose for UncertainDname
impl Compose for UncertainDname
Source§impl Debug for UncertainDname
impl Debug for UncertainDname
Source§impl Display for UncertainDname
impl Display for UncertainDname
Source§impl From<Dname> for UncertainDname
impl From<Dname> for UncertainDname
Source§impl From<RelativeDname> for UncertainDname
impl From<RelativeDname> for UncertainDname
Source§fn from(name: RelativeDname) -> Self
fn from(name: RelativeDname) -> Self
Source§impl FromStr for UncertainDname
impl FromStr for UncertainDname
Source§impl Hash for UncertainDname
impl Hash for UncertainDname
Source§impl PartialEq for UncertainDname
impl PartialEq for UncertainDname
Source§impl Scan for UncertainDname
impl Scan for UncertainDname
Source§impl<'a> ToLabelIter<'a> for UncertainDname
impl<'a> ToLabelIter<'a> for UncertainDname
Source§fn iter_labels(&'a self) -> Self::LabelIter
fn iter_labels(&'a self) -> Self::LabelIter
Source§fn starts_with<N: ToLabelIter<'a>>(&'a self, base: &'a N) -> bool
fn starts_with<N: ToLabelIter<'a>>(&'a self, base: &'a N) -> bool
base is a prefix of self.