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>

source

pub fn absolute(name: Dname<Octets>) -> Self

Creates a new uncertain domain name from an absolute domain name.

source

pub fn relative(name: RelativeDname<Octets>) -> Self

Creates a new uncertain domain name from a relative domain name.

source

pub fn root() -> Selfwhere Octets: From<&'static [u8]>,

Creates a new uncertain domain name containing the root label only.

source

pub fn empty() -> Selfwhere Octets: From<&'static [u8]>,

Creates a new uncertain yet empty domain name.

source

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.

source

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.

source

pub fn scan<S: Scanner<Dname = Dname<Octets>>>( scanner: &mut S ) -> Result<Self, S::Error>

source§

impl UncertainDname<&'static [u8]>

source

pub fn empty_ref() -> Self

Creates an empty relative name atop a slice reference.

source

pub fn root_ref() -> Self

Creates an absolute name that is the root label atop a slice reference.

source§

impl UncertainDname<Vec<u8>>

source

pub fn empty_vec() -> Self

Creates an empty relative name atop a Vec<u8>.

source

pub fn root_vec() -> Self

Creates an absolute name from the root label atop a Vec<u8>.

source§

impl UncertainDname<Bytes>

source

pub fn empty_bytes() -> Self

Creates an empty relative name atop a bytes value.

source

pub fn root_bytes() -> Self

Creates an absolute name from the root label atop a bytes value.

source§

impl<Octets> UncertainDname<Octets>

source

pub fn is_absolute(&self) -> bool

Returns whether the name is absolute.

source

pub fn is_relative(&self) -> bool

Returns whether the name is relative.

source

pub fn as_absolute(&self) -> Option<&Dname<Octets>>

Returns a reference to an absolute name, if this name is absolute.

source

pub fn as_relative(&self) -> Option<&RelativeDname<Octets>>

Returns a reference to a relative name, if the name is relative.

source

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.

source

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.

source

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.

source

pub fn as_octets(&self) -> &Octets

Returns a reference to the underlying octets sequence.

source

pub fn as_slice(&self) -> &[u8] where Octets: AsRef<[u8]>,

Returns an octets slice with the raw content of the name.

source

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<[u8]>> AsRef<[u8]> for UncertainDname<Octs>

source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<Octs> AsRef<Octs> for UncertainDname<Octs>

source§

fn as_ref(&self) -> &Octs

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<Octets: Clone> Clone for UncertainDname<Octets>

source§

fn clone(&self) -> UncertainDname<Octets>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<Octets: AsRef<[u8]>> Debug for UncertainDname<Octets>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<Octets: AsRef<[u8]>> Display for UncertainDname<Octets>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<Octets> From<Dname<Octets>> for UncertainDname<Octets>

source§

fn from(src: Dname<Octets>) -> Self

Converts to this type from the input type.
source§

impl<Octets> From<RelativeDname<Octets>> for UncertainDname<Octets>

source§

fn from(src: RelativeDname<Octets>) -> Self

Converts to this type from the input type.
source§

impl<Octets> FromStr for UncertainDname<Octets>where Octets: FromBuilder, <Octets as FromBuilder>::Builder: EmptyBuilder + FreezeBuilder<Octets = Octets> + AsRef<[u8]> + AsMut<[u8]>,

§

type Err = FromStrError

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
source§

impl<Octets: AsRef<[u8]>> Hash for UncertainDname<Octets>

source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<'a, Octets: AsRef<[u8]>> IntoIterator for &'a UncertainDname<Octets>

§

type Item = &'a Label

The type of the elements being iterated over.
§

type IntoIter = DnameIter<'a>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<Octets, Other> PartialEq<UncertainDname<Other>> for UncertainDname<Octets>where Octets: AsRef<[u8]>, Other: AsRef<[u8]>,

source§

fn eq(&self, other: &UncertainDname<Other>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<Octs: AsRef<[u8]>> ToLabelIter for UncertainDname<Octs>

§

type LabelIter<'a> = DnameIter<'a> where Octs: 'a

The type of the iterator over the labels. Read more
source§

fn iter_labels(&self) -> Self::LabelIter<'_>

Returns an iterator over the labels.
source§

fn compose_len(&self) -> u16

Returns the length in octets of the encoded name.
source§

fn starts_with<N: ToLabelIter + ?Sized>(&self, base: &N) -> bool

Determines whether base is a prefix of self.
source§

fn ends_with<N: ToLabelIter + ?Sized>(&self, base: &N) -> bool

Determines whether base is a suffix of self.
source§

impl<Octets: AsRef<[u8]>> Eq for UncertainDname<Octets>

Auto Trait Implementations§

§

impl<Octets> RefUnwindSafe for UncertainDname<Octets>where Octets: RefUnwindSafe,

§

impl<Octets> Send for UncertainDname<Octets>where Octets: Send,

§

impl<Octets> Sync for UncertainDname<Octets>where Octets: Sync,

§

impl<Octets> Unpin for UncertainDname<Octets>where Octets: Unpin,

§

impl<Octets> UnwindSafe for UncertainDname<Octets>where Octets: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<Source, Target> OctetsInto<Target> for Sourcewhere Target: OctetsFrom<Source>,

§

type Error = <Target as OctetsFrom<Source>>::Error

source§

fn try_octets_into( self ) -> Result<Target, <Source as OctetsInto<Target>>::Error>

Performs the conversion.
source§

fn octets_into(self) -> Targetwhere Self::Error: Into<Infallible>,

Performs an infallible conversion.
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

source§

fn vzip(self) -> V