pub enum UncertainName<Octets> {
Absolute(Name<Octets>),
Relative(RelativeName<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(Name<Octets>)
Relative(RelativeName<Octets>)
Implementations§
source§impl<Octets> UncertainName<Octets>
impl<Octets> UncertainName<Octets>
sourcepub fn absolute(name: Name<Octets>) -> Self
pub fn absolute(name: Name<Octets>) -> Self
Creates a new uncertain domain name from an absolute domain name.
sourcepub fn relative(name: RelativeName<Octets>) -> Self
pub fn relative(name: RelativeName<Octets>) -> Self
Creates a new uncertain domain name from a relative domain name.
sourcepub fn from_octets(octets: Octets) -> Result<Self, UncertainDnameError>
pub fn from_octets(octets: Octets) -> Result<Self, UncertainDnameError>
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<Name = Name<Octets>>>( scanner: &mut S, ) -> Result<Self, S::Error>
source§impl UncertainName<&'static [u8]>
impl UncertainName<&'static [u8]>
source§impl UncertainName<Vec<u8>>
impl UncertainName<Vec<u8>>
source§impl UncertainName<Bytes>
impl UncertainName<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> UncertainName<Octets>
impl<Octets> UncertainName<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<&Name<Octets>>
pub fn as_absolute(&self) -> Option<&Name<Octets>>
Returns a reference to an absolute name, if this name is absolute.
sourcepub fn as_relative(&self) -> Option<&RelativeName<Octets>>
pub fn as_relative(&self) -> Option<&RelativeName<Octets>>
Returns a reference to a relative name, if the name is relative.
sourcepub fn into_absolute(self) -> Result<Name<Octets>, PushError>where
Octets: AsRef<[u8]> + IntoBuilder,
<Octets as IntoBuilder>::Builder: FreezeBuilder<Octets = Octets> + AsRef<[u8]> + AsMut<[u8]>,
pub fn into_absolute(self) -> Result<Name<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
RelativeName::into_absolute
.
sourcepub fn try_into_absolute(self) -> Result<Name<Octets>, Self>
pub fn try_into_absolute(self) -> Result<Name<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<RelativeName<Octets>, Self>
pub fn try_into_relative(self) -> Result<RelativeName<Octets>, Self>
Converts the name into a relative name if it is relative.
Otherwise just returns itself as the error.
sourcepub fn chain<S: ToLabelIter>(
self,
suffix: S,
) -> Result<Chain<Self, S>, LongChainError>
pub fn chain<S: ToLabelIter>( 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<Octs> AsRef<Octs> for UncertainName<Octs>
impl<Octs> AsRef<Octs> for UncertainName<Octs>
source§impl<Octets: Clone> Clone for UncertainName<Octets>
impl<Octets: Clone> Clone for UncertainName<Octets>
source§fn clone(&self) -> UncertainName<Octets>
fn clone(&self) -> UncertainName<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<Name<Octets>> for UncertainName<Octets>
impl<Octets> From<Name<Octets>> for UncertainName<Octets>
source§impl<Octets> From<RelativeName<Octets>> for UncertainName<Octets>
impl<Octets> From<RelativeName<Octets>> for UncertainName<Octets>
source§fn from(src: RelativeName<Octets>) -> Self
fn from(src: RelativeName<Octets>) -> Self
source§impl<Octets> FromStr for UncertainName<Octets>where
Octets: FromBuilder,
<Octets as FromBuilder>::Builder: EmptyBuilder + FreezeBuilder<Octets = Octets> + AsRef<[u8]> + AsMut<[u8]>,
impl<Octets> FromStr for UncertainName<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 UncertainName<Octets>
impl<'a, Octets: AsRef<[u8]>> IntoIterator for &'a UncertainName<Octets>
source§impl<Octets, Other> PartialEq<UncertainName<Other>> for UncertainName<Octets>
impl<Octets, Other> PartialEq<UncertainName<Other>> for UncertainName<Octets>
source§impl<Octs: AsRef<[u8]>> ToLabelIter for UncertainName<Octs>
impl<Octs: AsRef<[u8]>> ToLabelIter for UncertainName<Octs>
source§type LabelIter<'a> = NameIter<'a>
where
Octs: 'a
type LabelIter<'a> = NameIter<'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
.impl<Octets: AsRef<[u8]>> Eq for UncertainName<Octets>
Auto Trait Implementations§
impl<Octets> Freeze for UncertainName<Octets>where
Octets: Freeze,
impl<Octets> RefUnwindSafe for UncertainName<Octets>where
Octets: RefUnwindSafe,
impl<Octets> Send for UncertainName<Octets>where
Octets: Send,
impl<Octets> Sync for UncertainName<Octets>where
Octets: Sync,
impl<Octets> Unpin for UncertainName<Octets>where
Octets: Unpin,
impl<Octets> UnwindSafe for UncertainName<Octets>where
Octets: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)